39#ifndef INCLUDE_NLOHMANN_JSON_HPP_
40#define INCLUDE_NLOHMANN_JSON_HPP_
42#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
43 #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
44 #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 10 || NLOHMANN_JSON_VERSION_PATCH != 5
45 #warning "Already included a different version of the library!"
50#define NLOHMANN_JSON_VERSION_MAJOR 3
51#define NLOHMANN_JSON_VERSION_MINOR 10
52#define NLOHMANN_JSON_VERSION_PATCH 5
57#include <initializer_list>
79#include <forward_list>
85#include <unordered_map>
167 static constexpr std::array<std::uint8_t, 9> order = {{
174 const auto l_index =
static_cast<std::size_t
>(lhs);
175 const auto r_index =
static_cast<std::size_t
>(rhs);
176 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
203#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
204#if defined(JSON_HEDLEY_VERSION)
205 #undef JSON_HEDLEY_VERSION
207#define JSON_HEDLEY_VERSION 15
209#if defined(JSON_HEDLEY_STRINGIFY_EX)
210 #undef JSON_HEDLEY_STRINGIFY_EX
212#define JSON_HEDLEY_STRINGIFY_EX(x) #x
214#if defined(JSON_HEDLEY_STRINGIFY)
215 #undef JSON_HEDLEY_STRINGIFY
217#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
219#if defined(JSON_HEDLEY_CONCAT_EX)
220 #undef JSON_HEDLEY_CONCAT_EX
222#define JSON_HEDLEY_CONCAT_EX(a,b) a##b
224#if defined(JSON_HEDLEY_CONCAT)
225 #undef JSON_HEDLEY_CONCAT
227#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
229#if defined(JSON_HEDLEY_CONCAT3_EX)
230 #undef JSON_HEDLEY_CONCAT3_EX
232#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
234#if defined(JSON_HEDLEY_CONCAT3)
235 #undef JSON_HEDLEY_CONCAT3
237#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
239#if defined(JSON_HEDLEY_VERSION_ENCODE)
240 #undef JSON_HEDLEY_VERSION_ENCODE
242#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
244#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
245 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
247#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
249#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
250 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
252#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
254#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
255 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
257#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
259#if defined(JSON_HEDLEY_GNUC_VERSION)
260 #undef JSON_HEDLEY_GNUC_VERSION
262#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
263 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
264#elif defined(__GNUC__)
265 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
268#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
269 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
271#if defined(JSON_HEDLEY_GNUC_VERSION)
272 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
274 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
277#if defined(JSON_HEDLEY_MSVC_VERSION)
278 #undef JSON_HEDLEY_MSVC_VERSION
280#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
281 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
282#elif defined(_MSC_FULL_VER) && !defined(__ICL)
283 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
284#elif defined(_MSC_VER) && !defined(__ICL)
285 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
288#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
289 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
291#if !defined(JSON_HEDLEY_MSVC_VERSION)
292 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
293#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
294 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
295#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
296 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
298 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
301#if defined(JSON_HEDLEY_INTEL_VERSION)
302 #undef JSON_HEDLEY_INTEL_VERSION
304#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
305 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
306#elif defined(__INTEL_COMPILER) && !defined(__ICL)
307 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
310#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
311 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
313#if defined(JSON_HEDLEY_INTEL_VERSION)
314 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
316 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
319#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
320 #undef JSON_HEDLEY_INTEL_CL_VERSION
322#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
323 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
326#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
327 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
329#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
330 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
332 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
335#if defined(JSON_HEDLEY_PGI_VERSION)
336 #undef JSON_HEDLEY_PGI_VERSION
338#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
339 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
342#if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
343 #undef JSON_HEDLEY_PGI_VERSION_CHECK
345#if defined(JSON_HEDLEY_PGI_VERSION)
346 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
348 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
351#if defined(JSON_HEDLEY_SUNPRO_VERSION)
352 #undef JSON_HEDLEY_SUNPRO_VERSION
354#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
355 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10)
356#elif defined(__SUNPRO_C)
357 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
358#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
359 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10)
360#elif defined(__SUNPRO_CC)
361 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
364#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
365 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
367#if defined(JSON_HEDLEY_SUNPRO_VERSION)
368 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
370 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
373#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
374 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
376#if defined(__EMSCRIPTEN__)
377 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
380#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
381 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
383#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
384 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
386 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
389#if defined(JSON_HEDLEY_ARM_VERSION)
390 #undef JSON_HEDLEY_ARM_VERSION
392#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
393 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
394#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
395 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
398#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
399 #undef JSON_HEDLEY_ARM_VERSION_CHECK
401#if defined(JSON_HEDLEY_ARM_VERSION)
402 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
404 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
407#if defined(JSON_HEDLEY_IBM_VERSION)
408 #undef JSON_HEDLEY_IBM_VERSION
410#if defined(__ibmxl__)
411 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
412#elif defined(__xlC__) && defined(__xlC_ver__)
413 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
414#elif defined(__xlC__)
415 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
418#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
419 #undef JSON_HEDLEY_IBM_VERSION_CHECK
421#if defined(JSON_HEDLEY_IBM_VERSION)
422 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
424 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
427#if defined(JSON_HEDLEY_TI_VERSION)
428 #undef JSON_HEDLEY_TI_VERSION
431 defined(__TI_COMPILER_VERSION__) && \
433 defined(__TMS470__) || defined(__TI_ARM__) || \
434 defined(__MSP430__) || \
435 defined(__TMS320C2000__) \
437#if (__TI_COMPILER_VERSION__ >= 16000000)
438 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
442#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
443 #undef JSON_HEDLEY_TI_VERSION_CHECK
445#if defined(JSON_HEDLEY_TI_VERSION)
446 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
448 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
451#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
452 #undef JSON_HEDLEY_TI_CL2000_VERSION
454#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
455 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
458#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
459 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
461#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
462 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
464 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
467#if defined(JSON_HEDLEY_TI_CL430_VERSION)
468 #undef JSON_HEDLEY_TI_CL430_VERSION
470#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
471 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
474#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
475 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
477#if defined(JSON_HEDLEY_TI_CL430_VERSION)
478 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
480 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
483#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
484 #undef JSON_HEDLEY_TI_ARMCL_VERSION
486#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
487 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
490#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
491 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
493#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
494 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
496 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
499#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
500 #undef JSON_HEDLEY_TI_CL6X_VERSION
502#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
503 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
506#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
507 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
509#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
510 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
512 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
515#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
516 #undef JSON_HEDLEY_TI_CL7X_VERSION
518#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
519 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
522#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
523 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
525#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
526 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
528 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
531#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
532 #undef JSON_HEDLEY_TI_CLPRU_VERSION
534#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
535 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
538#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
539 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
541#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
542 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
544 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
547#if defined(JSON_HEDLEY_CRAY_VERSION)
548 #undef JSON_HEDLEY_CRAY_VERSION
551 #if defined(_RELEASE_PATCHLEVEL)
552 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
554 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
558#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
559 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
561#if defined(JSON_HEDLEY_CRAY_VERSION)
562 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
564 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
567#if defined(JSON_HEDLEY_IAR_VERSION)
568 #undef JSON_HEDLEY_IAR_VERSION
570#if defined(__IAR_SYSTEMS_ICC__)
572 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
574 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
578#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
579 #undef JSON_HEDLEY_IAR_VERSION_CHECK
581#if defined(JSON_HEDLEY_IAR_VERSION)
582 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
584 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
587#if defined(JSON_HEDLEY_TINYC_VERSION)
588 #undef JSON_HEDLEY_TINYC_VERSION
590#if defined(__TINYC__)
591 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
594#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
595 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
597#if defined(JSON_HEDLEY_TINYC_VERSION)
598 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
600 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
603#if defined(JSON_HEDLEY_DMC_VERSION)
604 #undef JSON_HEDLEY_DMC_VERSION
607 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
610#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
611 #undef JSON_HEDLEY_DMC_VERSION_CHECK
613#if defined(JSON_HEDLEY_DMC_VERSION)
614 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
616 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
619#if defined(JSON_HEDLEY_COMPCERT_VERSION)
620 #undef JSON_HEDLEY_COMPCERT_VERSION
622#if defined(__COMPCERT_VERSION__)
623 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
626#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
627 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
629#if defined(JSON_HEDLEY_COMPCERT_VERSION)
630 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
632 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
635#if defined(JSON_HEDLEY_PELLES_VERSION)
636 #undef JSON_HEDLEY_PELLES_VERSION
639 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
642#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
643 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
645#if defined(JSON_HEDLEY_PELLES_VERSION)
646 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
648 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
651#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
652 #undef JSON_HEDLEY_MCST_LCC_VERSION
654#if defined(__LCC__) && defined(__LCC_MINOR__)
655 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
658#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
659 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
661#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
662 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
664 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
667#if defined(JSON_HEDLEY_GCC_VERSION)
668 #undef JSON_HEDLEY_GCC_VERSION
671 defined(JSON_HEDLEY_GNUC_VERSION) && \
672 !defined(__clang__) && \
673 !defined(JSON_HEDLEY_INTEL_VERSION) && \
674 !defined(JSON_HEDLEY_PGI_VERSION) && \
675 !defined(JSON_HEDLEY_ARM_VERSION) && \
676 !defined(JSON_HEDLEY_CRAY_VERSION) && \
677 !defined(JSON_HEDLEY_TI_VERSION) && \
678 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
679 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
680 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
681 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
682 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
683 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
684 !defined(__COMPCERT__) && \
685 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
686 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
689#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
690 #undef JSON_HEDLEY_GCC_VERSION_CHECK
692#if defined(JSON_HEDLEY_GCC_VERSION)
693 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
695 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
698#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
699 #undef JSON_HEDLEY_HAS_ATTRIBUTE
702 defined(__has_attribute) && \
704 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
706# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
708# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
711#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
712 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
714#if defined(__has_attribute)
715 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
717 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
720#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
721 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
723#if defined(__has_attribute)
724 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
726 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
729#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
730 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
733 defined(__has_cpp_attribute) && \
734 defined(__cplusplus) && \
735 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
736 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
738 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
741#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
742 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
744#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
745 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
747 !defined(JSON_HEDLEY_PGI_VERSION) && \
748 !defined(JSON_HEDLEY_IAR_VERSION) && \
749 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
750 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
751 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
753 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
756#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
757 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
759#if defined(__has_cpp_attribute) && defined(__cplusplus)
760 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
762 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
765#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
766 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
768#if defined(__has_cpp_attribute) && defined(__cplusplus)
769 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
771 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
774#if defined(JSON_HEDLEY_HAS_BUILTIN)
775 #undef JSON_HEDLEY_HAS_BUILTIN
777#if defined(__has_builtin)
778 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
780 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
783#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
784 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
786#if defined(__has_builtin)
787 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
789 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
792#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
793 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
795#if defined(__has_builtin)
796 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
798 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
801#if defined(JSON_HEDLEY_HAS_FEATURE)
802 #undef JSON_HEDLEY_HAS_FEATURE
804#if defined(__has_feature)
805 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
807 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
810#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
811 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
813#if defined(__has_feature)
814 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
816 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
819#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
820 #undef JSON_HEDLEY_GCC_HAS_FEATURE
822#if defined(__has_feature)
823 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
825 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
828#if defined(JSON_HEDLEY_HAS_EXTENSION)
829 #undef JSON_HEDLEY_HAS_EXTENSION
831#if defined(__has_extension)
832 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
834 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
837#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
838 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
840#if defined(__has_extension)
841 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
843 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
846#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
847 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
849#if defined(__has_extension)
850 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
852 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
855#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
856 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
858#if defined(__has_declspec_attribute)
859 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
861 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
864#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
865 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
867#if defined(__has_declspec_attribute)
868 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
870 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
873#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
874 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
876#if defined(__has_declspec_attribute)
877 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
879 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
882#if defined(JSON_HEDLEY_HAS_WARNING)
883 #undef JSON_HEDLEY_HAS_WARNING
885#if defined(__has_warning)
886 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
888 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
891#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
892 #undef JSON_HEDLEY_GNUC_HAS_WARNING
894#if defined(__has_warning)
895 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
897 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
900#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
901 #undef JSON_HEDLEY_GCC_HAS_WARNING
903#if defined(__has_warning)
904 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
906 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
910 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
911 defined(__clang__) || \
912 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
913 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
914 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
915 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
916 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
917 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
918 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
919 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
920 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
921 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
922 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
923 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
924 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
925 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
926 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
927 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
928 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
929#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
930 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
932 #define JSON_HEDLEY_PRAGMA(value)
935#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
936 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
938#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
939 #undef JSON_HEDLEY_DIAGNOSTIC_POP
941#if defined(__clang__)
942 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
943 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
944#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
945 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
946 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
947#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
948 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
949 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
951 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
952 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
953 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
954 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
955#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
956 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
957 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
959 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
960 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
961 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
962 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
963 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
964 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
965 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
966 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
967#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
968 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
969 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
971 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
972 #define JSON_HEDLEY_DIAGNOSTIC_POP
977#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
978 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
980#if defined(__cplusplus)
981# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
982# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
983# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
984# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
985 JSON_HEDLEY_DIAGNOSTIC_PUSH \
986 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
987 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
988 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
990 JSON_HEDLEY_DIAGNOSTIC_POP
992# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
993 JSON_HEDLEY_DIAGNOSTIC_PUSH \
994 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
995 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
997 JSON_HEDLEY_DIAGNOSTIC_POP
1000# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1001 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1002 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1004 JSON_HEDLEY_DIAGNOSTIC_POP
1008#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1009 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
1012#if defined(JSON_HEDLEY_CONST_CAST)
1013 #undef JSON_HEDLEY_CONST_CAST
1015#if defined(__cplusplus)
1016# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1018 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1019 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1020 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1021# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1022 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1023 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1025 JSON_HEDLEY_DIAGNOSTIC_POP \
1028# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1031#if defined(JSON_HEDLEY_REINTERPRET_CAST)
1032 #undef JSON_HEDLEY_REINTERPRET_CAST
1034#if defined(__cplusplus)
1035 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1037 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1040#if defined(JSON_HEDLEY_STATIC_CAST)
1041 #undef JSON_HEDLEY_STATIC_CAST
1043#if defined(__cplusplus)
1044 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1046 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1049#if defined(JSON_HEDLEY_CPP_CAST)
1050 #undef JSON_HEDLEY_CPP_CAST
1052#if defined(__cplusplus)
1053# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1054# define JSON_HEDLEY_CPP_CAST(T, expr) \
1055 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1056 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1058 JSON_HEDLEY_DIAGNOSTIC_POP
1059# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1060# define JSON_HEDLEY_CPP_CAST(T, expr) \
1061 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1062 _Pragma("diag_suppress=Pe137") \
1063 JSON_HEDLEY_DIAGNOSTIC_POP
1065# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1068# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1071#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1072 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1074#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1075 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1076#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1077 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1078#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1079 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1080#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1081 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1082#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1083 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1084#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1085 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1086#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1087 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1088#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1089 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1091 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1092 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1093 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1094 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1095 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1096 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1097 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1098 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1099 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1100 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1101 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1102 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1103#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1104 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1105#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1106 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1107#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1108 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1109#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1110 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1112 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1115#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1116 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1118#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1119 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1120#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1121 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1122#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1123 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1124#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1125 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1126#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1127 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1128#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1129 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1131 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1132 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1133 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1134 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1135 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1136#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1137 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1138#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1139 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1140#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1141 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1143 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1146#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1147 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1149#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1150 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1151#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1152 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1153#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1154 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1155#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1156 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1157#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1158 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1159#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1160 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1161#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1162 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1163#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1164 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1166 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1167 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1168 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1169 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1170#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1171 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1172#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1173 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1175 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1178#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1179 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1181#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1182 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1183#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1184 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1185#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1186 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1188 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1191#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1192 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1194#if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1195 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1196#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1197 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1198#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1199 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1200#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1201 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1203 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1206#if defined(JSON_HEDLEY_DEPRECATED)
1207 #undef JSON_HEDLEY_DEPRECATED
1209#if defined(JSON_HEDLEY_DEPRECATED_FOR)
1210 #undef JSON_HEDLEY_DEPRECATED_FOR
1213 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1214 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1215 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1216 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1218 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1219 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1220 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1221 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1222 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1223 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1224 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1225 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1226 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1227 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1228 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1229 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1230 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1231 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1232#elif defined(__cplusplus) && (__cplusplus >= 201402L)
1233 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1234 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1236 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1237 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1238 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1239 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1240 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1241 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1242 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1243 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1244 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1245 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1246 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1247 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1248 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1249 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1250 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1251 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1252 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1253 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1255 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1256 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1257 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1258 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1259 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1260#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1261 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1262 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1264 #define JSON_HEDLEY_DEPRECATED(since)
1265 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1268#if defined(JSON_HEDLEY_UNAVAILABLE)
1269 #undef JSON_HEDLEY_UNAVAILABLE
1272 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1273 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1274 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1275 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1276 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1278 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1281#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1282 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1284#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1285 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1288 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1289 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1290 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1291 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1292 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1293 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1294 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1295 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1296 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1297 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1298 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1299 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1300 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1301 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1302 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1303 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1304 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1305 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1306 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1307#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1308 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1309 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1310#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1311 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1312 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1313#elif defined(_Check_return_)
1314 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1315 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1317 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1318 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1321#if defined(JSON_HEDLEY_SENTINEL)
1322 #undef JSON_HEDLEY_SENTINEL
1325 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1326 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1327 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1328 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1329 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1330 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1332 #define JSON_HEDLEY_SENTINEL(position)
1335#if defined(JSON_HEDLEY_NO_RETURN)
1336 #undef JSON_HEDLEY_NO_RETURN
1338#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1339 #define JSON_HEDLEY_NO_RETURN __noreturn
1341 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1342 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1343 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1344#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1345 #define JSON_HEDLEY_NO_RETURN _Noreturn
1346#elif defined(__cplusplus) && (__cplusplus >= 201103L)
1347 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1349 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1350 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1351 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1352 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1353 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1354 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1355 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1356 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1357 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1358 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1359 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1360 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1361 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1362 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1363 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1364 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1365 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1366 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1367#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1368 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1370 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1371 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1372 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1373#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1374 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1375#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1376 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1377#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1378 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1380 #define JSON_HEDLEY_NO_RETURN
1383#if defined(JSON_HEDLEY_NO_ESCAPE)
1384 #undef JSON_HEDLEY_NO_ESCAPE
1386#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1387 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1389 #define JSON_HEDLEY_NO_ESCAPE
1392#if defined(JSON_HEDLEY_UNREACHABLE)
1393 #undef JSON_HEDLEY_UNREACHABLE
1395#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1396 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1398#if defined(JSON_HEDLEY_ASSUME)
1399 #undef JSON_HEDLEY_ASSUME
1402 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1403 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1404 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1405 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1406#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1407 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1409 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1410 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1411 #if defined(__cplusplus)
1412 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1414 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1418 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1419 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1420 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1421 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1422 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1423 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1424 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1425 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1426#elif defined(JSON_HEDLEY_ASSUME)
1427 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1429#if !defined(JSON_HEDLEY_ASSUME)
1430 #if defined(JSON_HEDLEY_UNREACHABLE)
1431 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1433 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1436#if defined(JSON_HEDLEY_UNREACHABLE)
1438 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1439 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1440 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1442 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1445 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1447#if !defined(JSON_HEDLEY_UNREACHABLE)
1448 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1452#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1453 #pragma clang diagnostic ignored "-Wpedantic"
1455#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1456 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1458#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1459 #if defined(__clang__)
1460 #pragma clang diagnostic ignored "-Wvariadic-macros"
1461 #elif defined(JSON_HEDLEY_GCC_VERSION)
1462 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1465#if defined(JSON_HEDLEY_NON_NULL)
1466 #undef JSON_HEDLEY_NON_NULL
1469 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1470 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1471 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1472 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1473 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1475 #define JSON_HEDLEY_NON_NULL(...)
1479#if defined(JSON_HEDLEY_PRINTF_FORMAT)
1480 #undef JSON_HEDLEY_PRINTF_FORMAT
1482#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1483 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1484#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1485 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1487 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1488 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1489 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1490 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1491 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1492 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1493 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1494 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1495 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1496 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1497 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1498 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1499 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1500 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1501 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1502 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1503 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1504 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1505#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1506 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1508 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1511#if defined(JSON_HEDLEY_CONSTEXPR)
1512 #undef JSON_HEDLEY_CONSTEXPR
1514#if defined(__cplusplus)
1515 #if __cplusplus >= 201103L
1516 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1519#if !defined(JSON_HEDLEY_CONSTEXPR)
1520 #define JSON_HEDLEY_CONSTEXPR
1523#if defined(JSON_HEDLEY_PREDICT)
1524 #undef JSON_HEDLEY_PREDICT
1526#if defined(JSON_HEDLEY_LIKELY)
1527 #undef JSON_HEDLEY_LIKELY
1529#if defined(JSON_HEDLEY_UNLIKELY)
1530 #undef JSON_HEDLEY_UNLIKELY
1532#if defined(JSON_HEDLEY_UNPREDICTABLE)
1533 #undef JSON_HEDLEY_UNPREDICTABLE
1535#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1536 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1539 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1540 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1541 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1542# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1543# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1544# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1545# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1546# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1548 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1549 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1550 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1551 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1552 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1553 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1554 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1555 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1556 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1557 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1558 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1559 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1560 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1561 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1562 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1563 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1564# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1565 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1566# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1568 double hedley_probability_ = (probability); \
1569 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1571# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1573 double hedley_probability_ = (probability); \
1574 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1576# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1577# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1579# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1580# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1581# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1582# define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1583# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1585#if !defined(JSON_HEDLEY_UNPREDICTABLE)
1586 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1589#if defined(JSON_HEDLEY_MALLOC)
1590 #undef JSON_HEDLEY_MALLOC
1593 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1594 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1595 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1596 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1597 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1598 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1599 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1600 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1601 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1602 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1603 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1604 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1605 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1606 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1607 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1608 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1609 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1610 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1611 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1612#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1613 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1615 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1616 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1617 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1619 #define JSON_HEDLEY_MALLOC
1622#if defined(JSON_HEDLEY_PURE)
1623 #undef JSON_HEDLEY_PURE
1626 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1627 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1628 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1629 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1630 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1631 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1632 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1633 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1634 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1635 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1636 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1637 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1638 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1639 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1640 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1641 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1642 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1643 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1644 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1645# define JSON_HEDLEY_PURE __attribute__((__pure__))
1646#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1647# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1648#elif defined(__cplusplus) && \
1650 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1651 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1652 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1654# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1656# define JSON_HEDLEY_PURE
1659#if defined(JSON_HEDLEY_CONST)
1660 #undef JSON_HEDLEY_CONST
1663 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1664 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1665 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1666 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1667 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1668 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1669 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1670 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1671 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1672 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1673 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1674 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1675 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1676 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1677 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1678 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1679 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1680 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1681 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1682 #define JSON_HEDLEY_CONST __attribute__((__const__))
1684 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1685 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1687 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1690#if defined(JSON_HEDLEY_RESTRICT)
1691 #undef JSON_HEDLEY_RESTRICT
1693#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1694 #define JSON_HEDLEY_RESTRICT restrict
1696 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1697 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1698 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1699 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1700 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1701 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1702 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1703 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1704 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1705 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1706 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1707 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1708 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1709 defined(__clang__) || \
1710 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1711 #define JSON_HEDLEY_RESTRICT __restrict
1712#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1713 #define JSON_HEDLEY_RESTRICT _Restrict
1715 #define JSON_HEDLEY_RESTRICT
1718#if defined(JSON_HEDLEY_INLINE)
1719 #undef JSON_HEDLEY_INLINE
1722 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1723 (defined(__cplusplus) && (__cplusplus >= 199711L))
1724 #define JSON_HEDLEY_INLINE inline
1726 defined(JSON_HEDLEY_GCC_VERSION) || \
1727 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1728 #define JSON_HEDLEY_INLINE __inline__
1730 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1731 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1732 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1733 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1734 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1735 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1736 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1737 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1738 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1739 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1740 #define JSON_HEDLEY_INLINE __inline
1742 #define JSON_HEDLEY_INLINE
1745#if defined(JSON_HEDLEY_ALWAYS_INLINE)
1746 #undef JSON_HEDLEY_ALWAYS_INLINE
1749 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1750 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1751 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1752 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1753 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1754 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1755 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1756 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1757 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1758 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1759 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1760 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1761 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1762 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1763 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1764 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1765 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1766 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1767 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1768# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1770 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1771 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1772# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1773#elif defined(__cplusplus) && \
1775 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1776 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1777 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1778 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1779 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1780 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1782# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1783#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1784# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1786# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1789#if defined(JSON_HEDLEY_NEVER_INLINE)
1790 #undef JSON_HEDLEY_NEVER_INLINE
1793 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1794 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1795 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1796 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1797 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1798 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1799 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1800 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1801 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1802 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1803 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1804 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1805 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1806 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1807 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1808 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1809 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1810 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1811 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1812 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1814 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1815 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1816 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1817#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1818 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1819#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1820 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1821#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1822 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1823#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1824 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1825#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1826 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1828 #define JSON_HEDLEY_NEVER_INLINE
1831#if defined(JSON_HEDLEY_PRIVATE)
1832 #undef JSON_HEDLEY_PRIVATE
1834#if defined(JSON_HEDLEY_PUBLIC)
1835 #undef JSON_HEDLEY_PUBLIC
1837#if defined(JSON_HEDLEY_IMPORT)
1838 #undef JSON_HEDLEY_IMPORT
1840#if defined(_WIN32) || defined(__CYGWIN__)
1841# define JSON_HEDLEY_PRIVATE
1842# define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1843# define JSON_HEDLEY_IMPORT __declspec(dllimport)
1846 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1847 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1848 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1849 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1850 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1851 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1853 defined(__TI_EABI__) && \
1855 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1856 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
1859 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1860# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
1861# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
1863# define JSON_HEDLEY_PRIVATE
1864# define JSON_HEDLEY_PUBLIC
1866# define JSON_HEDLEY_IMPORT extern
1869#if defined(JSON_HEDLEY_NO_THROW)
1870 #undef JSON_HEDLEY_NO_THROW
1873 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
1874 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1875 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1876 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1877 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
1879 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
1880 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1881 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1882 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
1884 #define JSON_HEDLEY_NO_THROW
1887#if defined(JSON_HEDLEY_FALL_THROUGH)
1888 #undef JSON_HEDLEY_FALL_THROUGH
1891 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
1892 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
1893 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1894 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
1895#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
1896 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
1897#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
1898 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
1899#elif defined(__fallthrough)
1900 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
1902 #define JSON_HEDLEY_FALL_THROUGH
1905#if defined(JSON_HEDLEY_RETURNS_NON_NULL)
1906 #undef JSON_HEDLEY_RETURNS_NON_NULL
1909 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
1910 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
1911 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1912 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
1913#elif defined(_Ret_notnull_)
1914 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
1916 #define JSON_HEDLEY_RETURNS_NON_NULL
1919#if defined(JSON_HEDLEY_ARRAY_PARAM)
1920 #undef JSON_HEDLEY_ARRAY_PARAM
1923 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
1924 !defined(__STDC_NO_VLA__) && \
1925 !defined(__cplusplus) && \
1926 !defined(JSON_HEDLEY_PGI_VERSION) && \
1927 !defined(JSON_HEDLEY_TINYC_VERSION)
1928 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
1930 #define JSON_HEDLEY_ARRAY_PARAM(name)
1933#if defined(JSON_HEDLEY_IS_CONSTANT)
1934 #undef JSON_HEDLEY_IS_CONSTANT
1936#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
1937 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
1941#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
1942 #undef JSON_HEDLEY_IS_CONSTEXPR_
1945 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
1946 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1947 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1948 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
1949 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1950 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1951 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1952 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
1953 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1954 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1955 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
1957#if !defined(__cplusplus)
1959 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
1960 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1961 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1962 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1963 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1964 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1965 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
1966#if defined(__INTPTR_TYPE__)
1967 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
1970 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
1974 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
1975 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
1976 !defined(JSON_HEDLEY_PGI_VERSION) && \
1977 !defined(JSON_HEDLEY_IAR_VERSION)) || \
1978 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1979 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
1980 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
1981 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1982 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
1983#if defined(__INTPTR_TYPE__)
1984 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
1987 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
1990 defined(JSON_HEDLEY_GCC_VERSION) || \
1991 defined(JSON_HEDLEY_INTEL_VERSION) || \
1992 defined(JSON_HEDLEY_TINYC_VERSION) || \
1993 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
1994 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
1995 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
1996 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
1997 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
1998 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
2000# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
2004 ((void*) ((expr) * 0L) ) : \
2005((struct { char v[sizeof(void) * 2]; } *) 1) \
2011#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2012 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2013 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
2015 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
2017 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2018 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2020 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2023#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2024 #undef JSON_HEDLEY_BEGIN_C_DECLS
2026#if defined(JSON_HEDLEY_END_C_DECLS)
2027 #undef JSON_HEDLEY_END_C_DECLS
2029#if defined(JSON_HEDLEY_C_DECL)
2030 #undef JSON_HEDLEY_C_DECL
2032#if defined(__cplusplus)
2033 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2034 #define JSON_HEDLEY_END_C_DECLS }
2035 #define JSON_HEDLEY_C_DECL extern "C"
2037 #define JSON_HEDLEY_BEGIN_C_DECLS
2038 #define JSON_HEDLEY_END_C_DECLS
2039 #define JSON_HEDLEY_C_DECL
2042#if defined(JSON_HEDLEY_STATIC_ASSERT)
2043 #undef JSON_HEDLEY_STATIC_ASSERT
2046 !defined(__cplusplus) && ( \
2047 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2048 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2049 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2050 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2051 defined(_Static_assert) \
2053# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2055 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2056 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2057 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2058# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2060# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2063#if defined(JSON_HEDLEY_NULL)
2064 #undef JSON_HEDLEY_NULL
2066#if defined(__cplusplus)
2067 #if __cplusplus >= 201103L
2068 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2070 #define JSON_HEDLEY_NULL NULL
2072 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2075 #define JSON_HEDLEY_NULL NULL
2077 #define JSON_HEDLEY_NULL ((void*) 0)
2080#if defined(JSON_HEDLEY_MESSAGE)
2081 #undef JSON_HEDLEY_MESSAGE
2083#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2084# define JSON_HEDLEY_MESSAGE(msg) \
2085 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2086 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2087 JSON_HEDLEY_PRAGMA(message msg) \
2088 JSON_HEDLEY_DIAGNOSTIC_POP
2090 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2091 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2092# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2093#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2094# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2095#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2096# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2097#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2098# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2100# define JSON_HEDLEY_MESSAGE(msg)
2103#if defined(JSON_HEDLEY_WARNING)
2104 #undef JSON_HEDLEY_WARNING
2106#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2107# define JSON_HEDLEY_WARNING(msg) \
2108 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2109 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2110 JSON_HEDLEY_PRAGMA(clang warning msg) \
2111 JSON_HEDLEY_DIAGNOSTIC_POP
2113 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2114 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2115 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2116# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2118 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2119 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2120# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2122# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2125#if defined(JSON_HEDLEY_REQUIRE)
2126 #undef JSON_HEDLEY_REQUIRE
2128#if defined(JSON_HEDLEY_REQUIRE_MSG)
2129 #undef JSON_HEDLEY_REQUIRE_MSG
2131#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2132# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2133# define JSON_HEDLEY_REQUIRE(expr) \
2134 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2135 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2136 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2137 JSON_HEDLEY_DIAGNOSTIC_POP
2138# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2139 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2140 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2141 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2142 JSON_HEDLEY_DIAGNOSTIC_POP
2144# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2145# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2148# define JSON_HEDLEY_REQUIRE(expr)
2149# define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2152#if defined(JSON_HEDLEY_FLAGS)
2153 #undef JSON_HEDLEY_FLAGS
2155#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2156 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2158 #define JSON_HEDLEY_FLAGS
2161#if defined(JSON_HEDLEY_FLAGS_CAST)
2162 #undef JSON_HEDLEY_FLAGS_CAST
2164#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2165# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2166 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2167 _Pragma("warning(disable:188)") \
2169 JSON_HEDLEY_DIAGNOSTIC_POP \
2172# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2175#if defined(JSON_HEDLEY_EMPTY_BASES)
2176 #undef JSON_HEDLEY_EMPTY_BASES
2179 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2180 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2181 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2183 #define JSON_HEDLEY_EMPTY_BASES
2188#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2189 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2191#if defined(__clang__)
2192 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2194 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2197#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2198 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2200#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2202#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2203 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2205#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2207#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2208 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2210#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2212#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2213 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2215#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2217#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2218 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2220#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2222#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2223 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2225#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2227#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2228 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2230#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2237#include <type_traits>
2270template<
class Default,
2272 template<
class...>
class Op,
2280template<
class Default,
template<
class...>
class Op,
class... Args>
2287template<
template<
class...>
class Op,
class... Args>
2290template<
template<
class...>
class Op,
class... Args>
2293template<
template<
class...>
class Op,
class... Args>
2296template<
class Default,
template<
class...>
class Op,
class... Args>
2299template<
class Default,
template<
class...>
class Op,
class... Args>
2302template<
class Expected,
template<
class...>
class Op,
class... Args>
2305template<
class To,
template<
class...>
class Op,
class... Args>
2307 std::is_convertible<
detected_t<Op, Args...>, To>;
2316#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2317 #if defined(__clang__)
2318 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2319 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2321 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2322 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2323 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2330#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2331 #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
2332 #define JSON_HAS_CPP_20
2333 #define JSON_HAS_CPP_17
2334 #define JSON_HAS_CPP_14
2335 #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
2336 #define JSON_HAS_CPP_17
2337 #define JSON_HAS_CPP_14
2338 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2339 #define JSON_HAS_CPP_14
2342 #define JSON_HAS_CPP_11
2345#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2346 #ifdef JSON_HAS_CPP_17
2347 #if defined(__cpp_lib_filesystem)
2348 #define JSON_HAS_FILESYSTEM 1
2349 #elif defined(__cpp_lib_experimental_filesystem)
2350 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2351 #elif !defined(__has_include)
2352 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2353 #elif __has_include(<filesystem>)
2354 #define JSON_HAS_FILESYSTEM 1
2355 #elif __has_include(<experimental/filesystem>)
2356 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2360 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2361 #undef JSON_HAS_FILESYSTEM
2362 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2366 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2367 #undef JSON_HAS_FILESYSTEM
2368 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2372 #if defined(__clang_major__) && __clang_major__ < 7
2373 #undef JSON_HAS_FILESYSTEM
2374 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2378 #if defined(_MSC_VER) && _MSC_VER < 1914
2379 #undef JSON_HAS_FILESYSTEM
2380 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2384 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2385 #undef JSON_HAS_FILESYSTEM
2386 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2390 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2391 #undef JSON_HAS_FILESYSTEM
2392 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2397#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2398 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2401#ifndef JSON_HAS_FILESYSTEM
2402 #define JSON_HAS_FILESYSTEM 0
2405#ifndef JSON_HAS_THREE_WAY_COMPARISON
2406 #if defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L \
2407 && defined(__cpp_impl_three_way_comparison)&& __cpp_impl_three_way_comparison >= 201907L
2408 #define JSON_HAS_THREE_WAY_COMPARISON 1
2410 #define JSON_HAS_THREE_WAY_COMPARISON 0
2414#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address)
2415 #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]]
2417 #define JSON_NO_UNIQUE_ADDRESS
2421#if defined(__clang__)
2422 #pragma clang diagnostic push
2423 #pragma clang diagnostic ignored "-Wdocumentation"
2424 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2428#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2429 #define JSON_THROW(exception) throw exception
2430 #define JSON_TRY try
2431 #define JSON_CATCH(exception) catch(exception)
2432 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2435 #define JSON_THROW(exception) std::abort()
2436 #define JSON_TRY if(true)
2437 #define JSON_CATCH(exception) if(false)
2438 #define JSON_INTERNAL_CATCH(exception) if(false)
2442#if defined(JSON_THROW_USER)
2444 #define JSON_THROW JSON_THROW_USER
2446#if defined(JSON_TRY_USER)
2448 #define JSON_TRY JSON_TRY_USER
2450#if defined(JSON_CATCH_USER)
2452 #define JSON_CATCH JSON_CATCH_USER
2453 #undef JSON_INTERNAL_CATCH
2454 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2456#if defined(JSON_INTERNAL_CATCH_USER)
2457 #undef JSON_INTERNAL_CATCH
2458 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2462#if !defined(JSON_ASSERT)
2464 #define JSON_ASSERT(x) assert(x)
2468#if defined(JSON_TESTS_PRIVATE)
2469 #define JSON_PRIVATE_UNLESS_TESTED public
2471 #define JSON_PRIVATE_UNLESS_TESTED private
2479#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2480 template<typename BasicJsonType> \
2481 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2483 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2484 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2485 auto it = std::find_if(std::begin(m), std::end(m), \
2486 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2488 return ej_pair.first == e; \
2490 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2492 template<typename BasicJsonType> \
2493 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2495 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2496 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2497 auto it = std::find_if(std::begin(m), std::end(m), \
2498 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2500 return ej_pair.second == j; \
2502 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2508#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2509 template<template<typename, typename, typename...> class ObjectType, \
2510 template<typename, typename...> class ArrayType, \
2511 class StringType, class BooleanType, class NumberIntegerType, \
2512 class NumberUnsignedType, class NumberFloatType, \
2513 template<typename> class AllocatorType, \
2514 template<typename, typename = void> class JSONSerializer, \
2517#define NLOHMANN_BASIC_JSON_TPL \
2518 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2519 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2520 AllocatorType, JSONSerializer, BinaryType>
2524#define NLOHMANN_JSON_EXPAND( x ) x
2525#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME
2526#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2527 NLOHMANN_JSON_PASTE64, \
2528 NLOHMANN_JSON_PASTE63, \
2529 NLOHMANN_JSON_PASTE62, \
2530 NLOHMANN_JSON_PASTE61, \
2531 NLOHMANN_JSON_PASTE60, \
2532 NLOHMANN_JSON_PASTE59, \
2533 NLOHMANN_JSON_PASTE58, \
2534 NLOHMANN_JSON_PASTE57, \
2535 NLOHMANN_JSON_PASTE56, \
2536 NLOHMANN_JSON_PASTE55, \
2537 NLOHMANN_JSON_PASTE54, \
2538 NLOHMANN_JSON_PASTE53, \
2539 NLOHMANN_JSON_PASTE52, \
2540 NLOHMANN_JSON_PASTE51, \
2541 NLOHMANN_JSON_PASTE50, \
2542 NLOHMANN_JSON_PASTE49, \
2543 NLOHMANN_JSON_PASTE48, \
2544 NLOHMANN_JSON_PASTE47, \
2545 NLOHMANN_JSON_PASTE46, \
2546 NLOHMANN_JSON_PASTE45, \
2547 NLOHMANN_JSON_PASTE44, \
2548 NLOHMANN_JSON_PASTE43, \
2549 NLOHMANN_JSON_PASTE42, \
2550 NLOHMANN_JSON_PASTE41, \
2551 NLOHMANN_JSON_PASTE40, \
2552 NLOHMANN_JSON_PASTE39, \
2553 NLOHMANN_JSON_PASTE38, \
2554 NLOHMANN_JSON_PASTE37, \
2555 NLOHMANN_JSON_PASTE36, \
2556 NLOHMANN_JSON_PASTE35, \
2557 NLOHMANN_JSON_PASTE34, \
2558 NLOHMANN_JSON_PASTE33, \
2559 NLOHMANN_JSON_PASTE32, \
2560 NLOHMANN_JSON_PASTE31, \
2561 NLOHMANN_JSON_PASTE30, \
2562 NLOHMANN_JSON_PASTE29, \
2563 NLOHMANN_JSON_PASTE28, \
2564 NLOHMANN_JSON_PASTE27, \
2565 NLOHMANN_JSON_PASTE26, \
2566 NLOHMANN_JSON_PASTE25, \
2567 NLOHMANN_JSON_PASTE24, \
2568 NLOHMANN_JSON_PASTE23, \
2569 NLOHMANN_JSON_PASTE22, \
2570 NLOHMANN_JSON_PASTE21, \
2571 NLOHMANN_JSON_PASTE20, \
2572 NLOHMANN_JSON_PASTE19, \
2573 NLOHMANN_JSON_PASTE18, \
2574 NLOHMANN_JSON_PASTE17, \
2575 NLOHMANN_JSON_PASTE16, \
2576 NLOHMANN_JSON_PASTE15, \
2577 NLOHMANN_JSON_PASTE14, \
2578 NLOHMANN_JSON_PASTE13, \
2579 NLOHMANN_JSON_PASTE12, \
2580 NLOHMANN_JSON_PASTE11, \
2581 NLOHMANN_JSON_PASTE10, \
2582 NLOHMANN_JSON_PASTE9, \
2583 NLOHMANN_JSON_PASTE8, \
2584 NLOHMANN_JSON_PASTE7, \
2585 NLOHMANN_JSON_PASTE6, \
2586 NLOHMANN_JSON_PASTE5, \
2587 NLOHMANN_JSON_PASTE4, \
2588 NLOHMANN_JSON_PASTE3, \
2589 NLOHMANN_JSON_PASTE2, \
2590 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2591#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2592#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2593#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2594#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2595#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2596#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6)
2597#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7)
2598#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8)
2599#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9)
2600#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10)
2601#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11)
2602#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12)
2603#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13)
2604#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14)
2605#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15)
2606#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16)
2607#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17)
2608#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18)
2609#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19)
2610#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20)
2611#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21)
2612#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22)
2613#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23)
2614#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24)
2615#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25)
2616#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26)
2617#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27)
2618#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28)
2619#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29)
2620#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30)
2621#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31)
2622#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32)
2623#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33)
2624#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34)
2625#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35)
2626#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36)
2627#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37)
2628#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38)
2629#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39)
2630#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40)
2631#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41)
2632#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42)
2633#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43)
2634#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44)
2635#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45)
2636#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46)
2637#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47)
2638#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48)
2639#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49)
2640#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50)
2641#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51)
2642#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52)
2643#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53)
2644#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54)
2645#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55)
2646#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56)
2647#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57)
2648#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58)
2649#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59)
2650#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60)
2651#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61)
2652#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62)
2653#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63)
2655#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2656#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2657#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1);
2664#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2665 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2666 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2668#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2669 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2670 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2677#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2678 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2679 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2681#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2682 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2683 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2692#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2693 namespace detail { \
2694 using std::std_name; \
2696 template<typename... T> \
2697 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2700 namespace detail2 { \
2701 struct std_name##_tag \
2705 template<typename... T> \
2706 std_name##_tag std_name(T&&...); \
2708 template<typename... T> \
2709 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2711 template<typename... T> \
2712 struct would_call_std_##std_name \
2714 static constexpr auto const value = ::nlohmann::detail:: \
2715 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2719 template<typename... T> \
2720 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2724#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2725 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2728#if JSON_USE_IMPLICIT_CONVERSIONS
2729 #define JSON_EXPLICIT
2731 #define JSON_EXPLICIT explicit
2734#ifndef JSON_DIAGNOSTICS
2735 #define JSON_DIAGNOSTICS 0
2757template<
typename StringType>
2759 const StringType& t)
2762 for (
auto pos = s.find(
f);
2763 pos != StringType::npos;
2764 s.replace(pos,
f.size(), t),
2765 pos = s.find(
f, pos + t.size()))
2776template<
typename StringType>
2791template<
typename StringType>
2792static void unescape(StringType& s)
2836#include <type_traits>
2850#ifdef JSON_HAS_CPP_14
2853using std::enable_if_t;
2854using std::index_sequence;
2855using std::make_index_sequence;
2856using std::index_sequence_for;
2861template<
bool B,
typename T =
void>
2888template <
typename T, T... Ints>
2892 static constexpr std::size_t
size() noexcept
2894 return sizeof...(Ints);
2903template <
size_t... Ints>
2906namespace utility_internal
2909template <
typename Seq,
size_t SeqSize,
size_t Rem>
2913template <
typename T, T... Ints,
size_t SeqSize>
2919template <
typename T, T... Ints,
size_t SeqSize>
2927template <
typename T,
size_t N>
2934template <
typename T>
2949template <
typename T, T N>
2965template <
typename... Ts>
2983#ifndef JSON_HAS_CPP_17
2985 template<
typename T>
2997#include <type_traits>
3018template<
typename It,
typename =
void>
3021template<
typename It>
3025 typename It::reference, typename It::iterator_category >>
3036template<
typename T,
typename =
void>
3086#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3087#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3109template<
typename T =
void,
typename SFINAE =
void>
3110struct adl_serializer;
3114template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3116 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3117 class StringType = std::string,
class BooleanType =
bool,
3118 class NumberIntegerType = std::int64_t,
3119 class NumberUnsignedType = std::uint64_t,
3120 class NumberFloatType = double,
3121 template<
typename U>
class AllocatorType = std::allocator,
3122 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3124 class BinaryType = std::vector<std::uint8_t>>
3129template<
typename BasicJsonType>
3140template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3185template<
typename BasicJsonContext>
3187 std::integral_constant < bool,
3188 is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
3189 || std::is_same<BasicJsonContext, std::nullptr_t>::value >
3230template<
typename T,
typename... Args>
3233template<
typename T,
typename... Args>
3236template<
typename T,
typename U>
3240template<
typename BasicJsonType,
typename T,
typename =
void>
3247template <
typename BasicJsonType,
typename T>
3253template<
typename BasicJsonType,
typename T>
3256 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3260 const BasicJsonType&, T&>
::value;
3265template<
typename BasicJsonType,
typename T,
typename =
void>
3268template<
typename BasicJsonType,
typename T>
3271 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3280template<
typename BasicJsonType,
typename T,
typename =
void>
3283template<
typename BasicJsonType,
typename T>
3286 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3297struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
3300template<
typename BasicJsonType>
3305 using type =
typename std::conditional < has_key_compare<object_t>::value,
3309template<
typename BasicJsonType>
3319template<
class B,
class... Bn>
3321: std::conditional<bool(B::value), conjunction<Bn...>, B>
::type {};
3324template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3329template <
typename T>
3332template <
typename T1,
typename T2>
3334 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3336template <
typename T1,
typename T2>
3338 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3340template <
typename... Ts>
3342 :
conjunction<is_default_constructible<Ts>...> {};
3344template <
typename... Ts>
3346 :
conjunction<is_default_constructible<Ts>...> {};
3349template <
typename T,
typename... Args>
3352template <
typename T1,
typename T2>
3355template <
typename T1,
typename T2>
3358template <
typename... Ts>
3361template <
typename... Ts>
3365template<
typename T,
typename =
void>
3387 using t_ref =
typename std::add_lvalue_reference<T>::type;
3395 static constexpr auto is_iterator_begin =
3399 static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value && is_iterator_begin;
3412template<
typename T,
typename =
void>
3418template<
typename BasicJsonType,
typename CompatibleObjectType,
3422template<
typename BasicJsonType,
typename CompatibleObjectType>
3424 BasicJsonType, CompatibleObjectType,
3433 typename CompatibleObjectType::key_type>
::value &&
3435 typename CompatibleObjectType::mapped_type>
::value;
3438template<
typename BasicJsonType,
typename CompatibleObjectType>
3442template<
typename BasicJsonType,
typename ConstructibleObjectType,
3446template<
typename BasicJsonType,
typename ConstructibleObjectType>
3448 BasicJsonType, ConstructibleObjectType,
3456 (std::is_move_assignable<ConstructibleObjectType>::value ||
3457 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3459 typename object_t::key_type>
::value &&
3461 typename object_t::mapped_type,
3462 typename ConstructibleObjectType::mapped_type >
::value)) ||
3464 typename ConstructibleObjectType::mapped_type>
::value ||
3467 typename ConstructibleObjectType::mapped_type >
::value);
3470template<
typename BasicJsonType,
typename ConstructibleObjectType>
3473 ConstructibleObjectType> {};
3475template<
typename BasicJsonType,
typename CompatibleStringType>
3482template<
typename BasicJsonType,
typename ConstructibleStringType>
3487 typename BasicJsonType::string_t>
::value;
3490template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3493template<
typename BasicJsonType,
typename CompatibleArrayType>
3495 BasicJsonType, CompatibleArrayType,
3501 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>
::value >>
3508template<
typename BasicJsonType,
typename CompatibleArrayType>
3512template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3515template<
typename BasicJsonType,
typename ConstructibleArrayType>
3517 BasicJsonType, ConstructibleArrayType,
3519 typename BasicJsonType::value_type>
::value >>
3520 : std::true_type {};
3522template<
typename BasicJsonType,
typename ConstructibleArrayType>
3524 BasicJsonType, ConstructibleArrayType,
3526 typename BasicJsonType::value_type>
::value&&
3529(std::is_move_assignable<ConstructibleArrayType>::value ||
3530 std::is_copy_assignable<ConstructibleArrayType>::value)&&
3536!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>
::value&&
3538 detected_t<range_value_t, ConstructibleArrayType >>
::value >>
3544 typename BasicJsonType::array_t::value_type>
::value ||
3552template<
typename BasicJsonType,
typename ConstructibleArrayType>
3556template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
3560template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3562 RealIntegerType, CompatibleNumberIntegerType,
3564 std::is_integral<CompatibleNumberIntegerType>
::value&&
3565 !std::is_same<bool, CompatibleNumberIntegerType>
::value >>
3573 CompatibleNumberIntegerType>
::value &&
3574 CompatibleLimits::is_integer &&
3575 RealLimits::is_signed == CompatibleLimits::is_signed;
3578template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3581 CompatibleNumberIntegerType> {};
3583template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3586template<
typename BasicJsonType,
typename CompatibleType>
3588 BasicJsonType, CompatibleType,
3595template<
typename BasicJsonType,
typename CompatibleType>
3599template<
typename T1,
typename T2>
3602template<
typename T1,
typename... Args>
3605template<
typename BasicJsonType,
typename T>
3608template<
typename BasicJsonType>
3611template<
typename BasicJsonType>
3616template<
template <
typename...>
class Primary,
typename T>
3619template<
template <
typename...>
class Primary,
typename... Args>
3626template<
typename Compare,
typename A,
typename B,
typename =
void>
3629template<
typename Compare,
typename A,
typename B>
3631decltype(
std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
3632decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
3633>> : std::true_type {};
3636template<
typename BasicJsonType,
typename KeyType>
3638 typename BasicJsonType::object_comparator_t,
3651template<
typename BasicJsonType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
3655 && !(ExcludeObjectKeyType && std::is_same<KeyType,
3656 typename BasicJsonType::object_t::key_type>
::value)
3657 && (!RequireTransparentComparator ||
is_detected <
3659 typename BasicJsonType::object_comparator_t >
::value)
3665template<
typename ObjectType,
typename KeyType>
3669template<
typename BasicJsonType,
typename KeyType>
3673 typename BasicJsonType::object_t, KeyType >
::value,
3679template <
typename T>
3689 template <
typename C>
static one test(
decltype(&C::capacity) ) ;
3692 enum {
value =
sizeof(test<T>(
nullptr)) ==
sizeof(
char) };
3696template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
3699 return static_cast<T
>(
value);
3702template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
3733template<
typename... Args>
3734inline std::size_t
concat_length(
const char* cstr, Args&& ... rest);
3736template<
typename StringType,
typename... Args>
3737inline std::size_t
concat_length(
const StringType& str, Args&& ... rest);
3739template<
typename... Args>
3745template<
typename... Args>
3749 return ::strlen(cstr) +
concat_length(std::forward<Args>(rest)...);
3752template<
typename StringType,
typename... Args>
3755 return str.size() +
concat_length(std::forward<Args>(rest)...);
3758template<
typename OutStringType>
3762template<
typename StringType,
typename Arg>
3765template<
typename StringType,
typename Arg>
3768template<
typename StringType,
typename Arg>
3771template<
typename StringType,
typename Arg>
3774template<
typename StringType,
typename Arg>
3775using string_can_append_iter =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().begin(), std::declval<const Arg&>().
end()));
3777template<
typename StringType,
typename Arg>
3780template<
typename StringType,
typename Arg>
3783template<
typename StringType,
typename Arg>
3786template <
typename OutStringType,
typename Arg,
typename... Args,
3787 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
3789inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest);
3791template <
typename OutStringType,
typename Arg,
typename... Args,
3792 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
3795inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
3797template <
typename OutStringType,
typename Arg,
typename... Args,
3798 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
3802inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
3804template<
typename OutStringType,
typename Arg,
typename... Args,
3806inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest)
3808 out.append(std::forward<Arg>(arg));
3812template <
typename OutStringType,
typename Arg,
typename... Args,
3813 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
3814 && detect_string_can_append_op<OutStringType, Arg>::value,
int > >
3815inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest)
3817 out += std::forward<Arg>(arg);
3821template <
typename OutStringType,
typename Arg,
typename... Args,
3822 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
3823 && !detect_string_can_append_op<OutStringType, Arg>::value
3824 && detect_string_can_append_iter<OutStringType, Arg>::value,
int > >
3825inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
3827 out.append(arg.begin(), arg.end());
3831template <
typename OutStringType,
typename Arg,
typename... Args,
3832 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
3833 && !detect_string_can_append_op<OutStringType, Arg>::value
3834 && !detect_string_can_append_iter<OutStringType, Arg>::value
3835 && detect_string_can_append_data<OutStringType, Arg>::value,
int > >
3836inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
3838 out.append(arg.data(), arg.size());
3842template<
typename OutStringType = std::string,
typename... Args>
3870 const char*
what() const noexcept
override
3880 exception(
int id_, const
char* what_arg) :
id(id_), m(what_arg) {}
3882 static std::string
name(
const std::string& ename,
int id_)
3884 return concat(
"[json.exception.", ename,
'.', std::to_string(id_),
"] ");
3892 template<
typename BasicJsonType>
3896 std::vector<std::string> tokens;
3897 for (
const auto* current = leaf_element; current !=
nullptr && current->m_parent !=
nullptr; current = current->m_parent)
3899 switch (current->m_parent->type())
3903 for (std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i)
3905 if (¤t->m_parent->m_value.array->operator[](i) == current)
3907 tokens.emplace_back(std::to_string(i));
3916 for (
const auto& element : *current->m_parent->m_value.object)
3918 if (&element.second == current)
3920 tokens.emplace_back(element.first.c_str());
3945 auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
3946 [](
const std::string &
a,
const std::string &
b)
3948 return concat(a,
'/', detail::escape(b));
3950 return concat(
'(', str,
") ");
3952 static_cast<void>(leaf_element);
3959 std::runtime_error m;
3976 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
3984 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
3985 static parse_error create(
int id_, std::size_t byte_,
const std::string& what_arg, BasicJsonContext context)
3988 (byte_ != 0 ? (
concat(
" at byte ", std::to_string(byte_))) :
""),
3990 return {id_, byte_,
w.c_str()};
4005 parse_error(
int id_, std::size_t byte_,
const char* what_arg)
4008 static std::string position_string(
const position_t& pos)
4020 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4024 return {id_,
w.c_str()};
4038 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4042 return {id_,
w.c_str()};
4055 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4059 return {id_,
w.c_str()};
4072 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4076 return {id_,
w.c_str()};
4099template <
class T>
struct identity_tag {};
4110#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4111#include <experimental/filesystem>
4114namespace std_fs = std::experimental::filesystem;
4116#elif JSON_HAS_FILESYSTEM
4117#include <filesystem>
4120namespace std_fs = std::filesystem;
4128template<
typename BasicJsonType>
4129void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
4139template <
typename BasicJsonType,
typename ArithmeticType,
4140 enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
4141 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4143void get_arithmetic_value(
const BasicJsonType& j, ArithmeticType&
val)
4145 switch (
static_cast<value_t>(j))
4149 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4154 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4159 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4175template<
typename BasicJsonType>
4176void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t&
b)
4182 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4185template<
typename BasicJsonType>
4186void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
4192 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4196 typename BasicJsonType,
typename StringType,
4198 std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
4199 && !std::is_same<typename BasicJsonType::string_t, StringType>::value
4200 && !is_json_ref<StringType>::value,
int > = 0 >
4201void from_json(
const BasicJsonType& j, StringType& s)
4208 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4211template<
typename BasicJsonType>
4212void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t&
val)
4214 get_arithmetic_value(j,
val);
4217template<
typename BasicJsonType>
4218void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t&
val)
4220 get_arithmetic_value(j,
val);
4223template<
typename BasicJsonType>
4224void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t&
val)
4226 get_arithmetic_value(j,
val);
4229template<
typename BasicJsonType,
typename EnumType,
4230 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4231void from_json(
const BasicJsonType& j, EnumType& e)
4233 typename std::underlying_type<EnumType>::type
val;
4234 get_arithmetic_value(j,
val);
4235 e =
static_cast<EnumType
>(
val);
4239template<
typename BasicJsonType,
typename T,
typename Allocator,
4240 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4241void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
4249 std::front_inserter(l), [](
const BasicJsonType & i)
4251 return i.template get<T>();
4256template<
typename BasicJsonType,
typename T,
4257 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4258void from_json(
const BasicJsonType& j, std::valarray<T>& l)
4266 [](
const BasicJsonType & elem)
4268 return elem.template get<T>();
4272template<
typename BasicJsonType,
typename T, std::
size_t N>
4273auto from_json(
const BasicJsonType& j, T (&arr)[N])
4276 for (std::size_t i = 0; i < N; ++i)
4278 arr[i] = j.at(i).template
get<T>();
4282template<
typename BasicJsonType>
4283void from_json_array_impl(
const BasicJsonType& j,
typename BasicJsonType::array_t& arr, priority_tag<3> )
4285 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
4288template<
typename BasicJsonType,
typename T, std::
size_t N>
4289auto from_json_array_impl(
const BasicJsonType& j, std::array<T, N>& arr,
4293 for (std::size_t i = 0; i < N; ++i)
4295 arr[i] = j.at(i).template
get<T>();
4299template<
typename BasicJsonType,
typename ConstructibleArrayType,
4301 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4303auto from_json_array_impl(
const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> )
4305 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4311 ConstructibleArrayType ret;
4312 ret.reserve(j.size());
4314 std::inserter(ret,
end(ret)), [](
const BasicJsonType & i)
4323template<
typename BasicJsonType,
typename ConstructibleArrayType,
4325 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4327void from_json_array_impl(
const BasicJsonType& j, ConstructibleArrayType& arr,
4332 ConstructibleArrayType ret;
4334 j.begin(), j.end(), std::inserter(ret,
end(ret)),
4335 [](
const BasicJsonType & i)
4344template <
typename BasicJsonType,
typename ConstructibleArrayType,
4346 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
4347 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
4349 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
4350 !is_basic_json<ConstructibleArrayType>::value,
4352auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
4353->
decltype(from_json_array_impl(j, arr, priority_tag<3> {}),
4362 from_json_array_impl(j, arr, priority_tag<3> {});
4365template <
typename BasicJsonType,
typename T, std::size_t... Idx >
4366std::array<T,
sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType&& j,
4367 identity_tag<std::array<T,
sizeof...(Idx)>> ,
index_sequence<Idx...> )
4369 return { { std::forward<BasicJsonType>(j).at(Idx).template
get<T>()... } };
4372template <
typename BasicJsonType,
typename T, std::
size_t N >
4373auto from_json(BasicJsonType&& j, identity_tag<std::array<T, N>> tag)
4374->
decltype(from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N> {}))
4381 return from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N> {});
4384template<
typename BasicJsonType>
4385void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
4392 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
4395template<
typename BasicJsonType,
typename ConstructibleObjectType,
4396 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
4397void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
4404 ConstructibleObjectType ret;
4405 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
4406 using value_type =
typename ConstructibleObjectType::value_type;
4408 inner_object->begin(), inner_object->end(),
4409 std::inserter(ret, ret.begin()),
4410 [](
typename BasicJsonType::object_t::value_type
const & p)
4412 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
4421template <
typename BasicJsonType,
typename ArithmeticType,
4423 std::is_arithmetic<ArithmeticType>::value&&
4424 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
4425 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
4426 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
4427 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4429void from_json(
const BasicJsonType& j, ArithmeticType&
val)
4431 switch (
static_cast<value_t>(j))
4435 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4440 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4445 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4450 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
4465template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
4466std::tuple<Args...> from_json_tuple_impl_base(BasicJsonType&& j, index_sequence<Idx...> )
4468 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
4471template <
typename BasicJsonType,
class A1,
class A2 >
4472std::pair<A1, A2> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::pair<A1, A2>> , priority_tag<0> )
4474 return {std::forward<BasicJsonType>(j).at(0).template
get<A1>(),
4475 std::forward<BasicJsonType>(j).at(1).template
get<A2>()};
4478template<
typename BasicJsonType,
typename A1,
typename A2>
4479void from_json_tuple_impl(BasicJsonType&& j, std::pair<A1, A2>& p, priority_tag<1> )
4481 p = from_json_tuple_impl(std::forward<BasicJsonType>(j), identity_tag<std::pair<A1, A2>> {}, priority_tag<0> {});
4484template<
typename BasicJsonType,
typename... Args>
4485std::tuple<Args...> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::tuple<Args...>> , priority_tag<2> )
4487 return from_json_tuple_impl_base<BasicJsonType, Args...>(std::forward<BasicJsonType>(j),
index_sequence_for<Args...> {});
4490template<
typename BasicJsonType,
typename... Args>
4491void from_json_tuple_impl(BasicJsonType&& j, std::tuple<Args...>& t, priority_tag<3> )
4493 t = from_json_tuple_impl_base<BasicJsonType, Args...>(std::forward<BasicJsonType>(j),
index_sequence_for<Args...> {});
4496template<
typename BasicJsonType,
typename TupleRelated>
4497auto from_json(BasicJsonType&& j, TupleRelated&& t)
4498->
decltype(from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {}))
4505 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
4508template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
4510 typename BasicJsonType::string_t, Key >
::value >>
4511void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
4518 for (
const auto& p : j)
4528template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
4530 typename BasicJsonType::string_t, Key >
::value >>
4531void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
4538 for (
const auto& p : j)
4548#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
4549template<
typename BasicJsonType>
4550void from_json(
const BasicJsonType& j, std_fs::path& p)
4556 p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4562 template<
typename BasicJsonType,
typename T>
4563 auto operator()(
const BasicJsonType& j, T&&
val)
const
4564 noexcept(
noexcept(from_json(j, std::forward<T>(
val))))
4565 ->
decltype(from_json(j, std::forward<T>(
val)))
4567 return from_json(j, std::forward<T>(
val));
4588#include <type_traits>
4613template<
typename string_type>
4614void int_to_string( string_type&
target, std::size_t
value )
4617 using std::to_string;
4620template<
typename IteratorType>
class iteration_proxy_value
4623 using difference_type = std::ptrdiff_t;
4624 using value_type = iteration_proxy_value;
4625 using pointer = value_type * ;
4626 using reference = value_type & ;
4627 using iterator_category = std::input_iterator_tag;
4628 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().key() ) >
::type >
::type;
4632 IteratorType anchor;
4634 std::size_t array_index = 0;
4636 mutable std::size_t array_index_last = 0;
4638 mutable string_type array_index_str =
"0";
4640 const string_type empty_str{};
4643 explicit iteration_proxy_value(IteratorType it) noexcept
4654 iteration_proxy_value& operator++()
4663 bool operator==(
const iteration_proxy_value& o)
const
4665 return anchor == o.anchor;
4669 bool operator!=(
const iteration_proxy_value& o)
const
4671 return anchor != o.anchor;
4675 const string_type& key()
const
4679 switch (anchor.m_object->type())
4684 if (array_index != array_index_last)
4686 int_to_string( array_index_str, array_index );
4687 array_index_last = array_index;
4689 return array_index_str;
4694 return anchor.key();
4711 typename IteratorType::reference
value()
const
4713 return anchor.value();
4718template<
typename IteratorType>
class iteration_proxy
4722 typename IteratorType::reference container;
4726 explicit iteration_proxy(
typename IteratorType::reference cont) noexcept
4727 : container(cont) {}
4730 iteration_proxy_value<IteratorType>
begin() noexcept
4732 return iteration_proxy_value<IteratorType>(container.begin());
4736 iteration_proxy_value<IteratorType>
end() noexcept
4738 return iteration_proxy_value<IteratorType>(container.end());
4744template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
4745auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.key())
4752template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
4753auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.value())
4766#if defined(__clang__)
4768 #pragma clang diagnostic push
4769 #pragma clang diagnostic ignored "-Wmismatched-tags"
4771template<
typename IteratorType>
4772class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
4773 :
public std::integral_constant<std::size_t, 2> {};
4775template<std::
size_t N,
typename IteratorType>
4776class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
4781 ::nlohmann::detail::iteration_proxy_value<IteratorType >> ()));
4783#if defined(__clang__)
4784 #pragma clang diagnostic pop
4795#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4796#include <experimental/filesystem>
4799namespace std_fs = std::experimental::filesystem;
4801#elif JSON_HAS_FILESYSTEM
4802#include <filesystem>
4805namespace std_fs = std::filesystem;
4829 template<
typename BasicJsonType>
4830 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t
b)
noexcept
4832 j.m_value.destroy(j.m_type);
4835 j.assert_invariant();
4842 template<
typename BasicJsonType>
4843 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
4845 j.m_value.destroy(j.m_type);
4848 j.assert_invariant();
4851 template<
typename BasicJsonType>
4852 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
4854 j.m_value.destroy(j.m_type);
4857 j.assert_invariant();
4860 template <
typename BasicJsonType,
typename CompatibleStringType,
4861 enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
4863 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
4865 j.m_value.destroy(j.m_type);
4867 j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
4868 j.assert_invariant();
4875 template<
typename BasicJsonType>
4876 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t&
b)
4878 j.m_value.destroy(j.m_type);
4880 j.m_value =
typename BasicJsonType::binary_t(
b);
4881 j.assert_invariant();
4884 template<
typename BasicJsonType>
4885 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&&
b)
4887 j.m_value.destroy(j.m_type);
4889 j.m_value =
typename BasicJsonType::binary_t(
std::move(
b));
4890 j.assert_invariant();
4897 template<
typename BasicJsonType>
4898 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t
val)
noexcept
4900 j.m_value.destroy(j.m_type);
4903 j.assert_invariant();
4910 template<
typename BasicJsonType>
4911 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t
val)
noexcept
4913 j.m_value.destroy(j.m_type);
4916 j.assert_invariant();
4923 template<
typename BasicJsonType>
4924 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t
val)
noexcept
4926 j.m_value.destroy(j.m_type);
4929 j.assert_invariant();
4936 template<
typename BasicJsonType>
4937 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
4939 j.m_value.destroy(j.m_type);
4943 j.assert_invariant();
4946 template<
typename BasicJsonType>
4947 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
4949 j.m_value.destroy(j.m_type);
4953 j.assert_invariant();
4956 template <
typename BasicJsonType,
typename CompatibleArrayType,
4957 enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
4959 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
4964 j.m_value.destroy(j.m_type);
4966 j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr),
end(arr));
4968 j.assert_invariant();
4971 template<
typename BasicJsonType>
4972 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
4974 j.m_value.destroy(j.m_type);
4977 j.m_value.array->reserve(arr.size());
4978 for (
const bool x : arr)
4980 j.m_value.array->push_back(
x);
4981 j.set_parent(j.m_value.array->back());
4983 j.assert_invariant();
4986 template<
typename BasicJsonType,
typename T,
4988 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
4990 j.m_value.destroy(j.m_type);
4993 j.m_value.array->resize(arr.size());
4996 std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
4999 j.assert_invariant();
5006 template<
typename BasicJsonType>
5007 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
5009 j.m_value.destroy(j.m_type);
5013 j.assert_invariant();
5016 template<
typename BasicJsonType>
5017 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5019 j.m_value.destroy(j.m_type);
5023 j.assert_invariant();
5026 template <
typename BasicJsonType,
typename CompatibleObjectType,
5027 enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value,
int > = 0 >
5028 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
5033 j.m_value.destroy(j.m_type);
5035 j.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj),
end(obj));
5037 j.assert_invariant();
5045template<
typename BasicJsonType,
typename T,
5046 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value,
int> = 0>
5052template<
typename BasicJsonType,
typename CompatibleString,
5053 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
5054void to_json(BasicJsonType& j,
const CompatibleString& s)
5059template<
typename BasicJsonType>
5060void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5065template<
typename BasicJsonType,
typename FloatType,
5066 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
5072template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
5073 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
5074void to_json(BasicJsonType& j, CompatibleNumberUnsignedType
val)
noexcept
5079template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
5080 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
5081void to_json(BasicJsonType& j, CompatibleNumberIntegerType
val)
noexcept
5086template<
typename BasicJsonType,
typename EnumType,
5087 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
5088void to_json(BasicJsonType& j, EnumType e)
noexcept
5090 using underlying_type =
typename std::underlying_type<EnumType>::type;
5094template<
typename BasicJsonType>
5095void to_json(BasicJsonType& j,
const std::vector<bool>& e)
5100template <
typename BasicJsonType,
typename CompatibleArrayType,
5101 enable_if_t < is_compatible_array_type<BasicJsonType,
5103 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
5105 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
5106 !is_basic_json<CompatibleArrayType>::value,
5108void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
5113template<
typename BasicJsonType>
5114void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
5119template<
typename BasicJsonType,
typename T,
5120 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
5121void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
5126template<
typename BasicJsonType>
5127void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5132template <
typename BasicJsonType,
typename CompatibleObjectType,
5133 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value,
int > = 0 >
5134void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
5139template<
typename BasicJsonType>
5140void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5146 typename BasicJsonType,
typename T, std::size_t N,
5147 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
5155template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
5156void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
5158 j = { p.first, p.second };
5162template<
typename BasicJsonType,
typename T,
5163 enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>
::value,
int> = 0>
5166 j = { {
b.key(),
b.value()} };
5169template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
5172 j = { std::get<Idx>(t)... };
5175template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
5176void to_json(BasicJsonType& j,
const T& t)
5181#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5182template<
typename BasicJsonType>
5183void to_json(BasicJsonType& j,
const std_fs::path& p)
5191 template<
typename BasicJsonType,
typename T>
5218template<
typename ValueType,
typename>
5223 template<
typename BasicJsonType,
typename TargetType = ValueType>
5225 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j),
val)))
5226 ->
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j),
val),
void())
5228 ::nlohmann::from_json(std::forward<BasicJsonType>(j),
val);
5233 template<
typename BasicJsonType,
typename TargetType = ValueType>
5235 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {})))
5236 ->
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {}))
5238 return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {});
5243 template<
typename BasicJsonType,
typename TargetType = ValueType>
5244 static auto to_json(BasicJsonType& j, TargetType &&
val)
noexcept(
5245 noexcept(::nlohmann::to_json(j, std::forward<TargetType>(
val))))
5246 ->
decltype(::nlohmann::to_json(j, std::forward<TargetType>(
val)),
void())
5248 ::nlohmann::to_json(j, std::forward<TargetType>(
val));
5265template<
typename BinaryType>
5290 , m_subtype(subtype_)
5291 , m_has_subtype(
true)
5297 , m_subtype(subtype_)
5298 , m_has_subtype(
true)
5303 return std::tie(
static_cast<const BinaryType&
>(*
this), m_subtype, m_has_subtype) ==
5304 std::tie(
static_cast<const BinaryType&
>(rhs), rhs.m_subtype, rhs.m_has_subtype);
5309 return !(rhs == *
this);
5316 m_subtype = subtype_;
5317 m_has_subtype =
true;
5324 return m_has_subtype ? m_subtype :
static_cast<subtype_type>(-1);
5331 return m_has_subtype;
5339 m_has_subtype =
false;
5344 bool m_has_subtype =
false;
5360#include <functional>
5373inline std::size_t combine(std::size_t seed, std::size_t h)
noexcept
5375 seed ^= h + 0x9e3779b9 + (
seed << 6U) + (seed >> 2U);
5390template<
typename BasicJsonType>
5391std::size_t hash(
const BasicJsonType& j)
5393 using string_t =
typename BasicJsonType::string_t;
5394 using number_integer_t =
typename BasicJsonType::number_integer_t;
5395 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
5396 using number_float_t =
typename BasicJsonType::number_float_t;
5398 const auto type =
static_cast<std::size_t
>(j.type());
5401 case BasicJsonType::value_t::null:
5402 case BasicJsonType::value_t::discarded:
5404 return combine(
type, 0);
5407 case BasicJsonType::value_t::object:
5409 auto seed = combine(
type, j.size());
5410 for (
const auto& element : j.items())
5412 const auto h = std::hash<string_t> {}(element.key());
5413 seed = combine(seed, h);
5414 seed = combine(seed, hash(element.value()));
5419 case BasicJsonType::value_t::array:
5421 auto seed = combine(
type, j.size());
5422 for (
const auto& element : j)
5424 seed = combine(seed, hash(element));
5429 case BasicJsonType::value_t::string:
5431 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
5432 return combine(
type, h);
5435 case BasicJsonType::value_t::boolean:
5437 const auto h = std::hash<bool> {}(j.template
get<bool>());
5438 return combine(
type, h);
5441 case BasicJsonType::value_t::number_integer:
5444 return combine(
type, h);
5447 case BasicJsonType::value_t::number_unsigned:
5450 return combine(
type, h);
5453 case BasicJsonType::value_t::number_float:
5456 return combine(
type, h);
5459 case BasicJsonType::value_t::binary:
5461 auto seed = combine(
type, j.get_binary().size());
5462 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
5463 seed = combine(seed, h);
5464 seed = combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
5465 for (
const auto byte : j.get_binary())
5467 seed = combine(seed, std::hash<std::uint8_t> {}(
byte));
5510#include <type_traits>
5528enum class input_format_t {
json, cbor, msgpack, ubjson, bson, bjdata };
5539class file_input_adapter
5542 using char_type = char;
5545 explicit file_input_adapter(
std::FILE*
f) noexcept
5550 file_input_adapter(
const file_input_adapter&) =
delete;
5551 file_input_adapter(file_input_adapter&&) noexcept = default;
5552 file_input_adapter& operator=(const file_input_adapter&) = delete;
5553 file_input_adapter& operator=(file_input_adapter&&) = delete;
5554 ~file_input_adapter() = default;
5556 std::char_traits<
char>::int_type get_character() noexcept
5558 return std::fgetc(m_file);
5576class input_stream_adapter
5579 using char_type = char;
5581 ~input_stream_adapter()
5587 is->clear(
is->rdstate() & std::ios::eofbit);
5591 explicit input_stream_adapter(std::istream& i)
5592 :
is(&i), sb(i.rdbuf())
5596 input_stream_adapter(
const input_stream_adapter&) =
delete;
5597 input_stream_adapter& operator=(input_stream_adapter&) =
delete;
5598 input_stream_adapter& operator=(input_stream_adapter&&) =
delete;
5600 input_stream_adapter(input_stream_adapter&& rhs) noexcept
5601 :
is(rhs.is), sb(rhs.sb)
5610 std::char_traits<char>::int_type get_character()
5612 auto res = sb->sbumpc();
5616 is->clear(
is->rdstate() | std::ios::eofbit);
5623 std::istream*
is =
nullptr;
5624 std::streambuf* sb =
nullptr;
5630template<
typename IteratorType>
5631class iterator_input_adapter
5634 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
5636 iterator_input_adapter(IteratorType
first, IteratorType last)
5640 typename std::char_traits<char_type>::int_type get_character()
5644 auto result = std::char_traits<char_type>::to_int_type(*current);
5645 std::advance(current, 1);
5649 return std::char_traits<char_type>::eof();
5653 IteratorType current;
5656 template<
typename BaseInputAdapter,
size_t T>
5657 friend struct wide_string_input_helper;
5661 return current ==
end;
5666template<
typename BaseInputAdapter,
size_t T>
5667struct wide_string_input_helper;
5669template<
typename BaseInputAdapter>
5670struct wide_string_input_helper<BaseInputAdapter, 4>
5673 static void fill_buffer(BaseInputAdapter& input,
5674 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5675 size_t& utf8_bytes_index,
5676 size_t& utf8_bytes_filled)
5678 utf8_bytes_index = 0;
5682 utf8_bytes[0] = std::char_traits<char>::eof();
5683 utf8_bytes_filled = 1;
5688 const auto wc = input.get_character();
5693 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5694 utf8_bytes_filled = 1;
5696 else if (wc <= 0x7FF)
5698 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
5699 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5700 utf8_bytes_filled = 2;
5702 else if (wc <= 0xFFFF)
5704 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
5705 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5706 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5707 utf8_bytes_filled = 3;
5709 else if (wc <= 0x10FFFF)
5711 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
5712 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
5713 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5714 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5715 utf8_bytes_filled = 4;
5720 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5721 utf8_bytes_filled = 1;
5727template<
typename BaseInputAdapter>
5728struct wide_string_input_helper<BaseInputAdapter, 2>
5731 static void fill_buffer(BaseInputAdapter& input,
5732 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5733 size_t& utf8_bytes_index,
5734 size_t& utf8_bytes_filled)
5736 utf8_bytes_index = 0;
5740 utf8_bytes[0] = std::char_traits<char>::eof();
5741 utf8_bytes_filled = 1;
5746 const auto wc = input.get_character();
5751 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5752 utf8_bytes_filled = 1;
5754 else if (wc <= 0x7FF)
5756 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
5757 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5758 utf8_bytes_filled = 2;
5760 else if (0xD800 > wc || wc >= 0xE000)
5762 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
5763 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5764 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5765 utf8_bytes_filled = 3;
5771 const auto wc2 =
static_cast<unsigned int>(input.get_character());
5772 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
5773 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
5774 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
5775 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
5776 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
5777 utf8_bytes_filled = 4;
5781 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5782 utf8_bytes_filled = 1;
5790template<
typename BaseInputAdapter,
typename W
ideCharType>
5791class wide_string_input_adapter
5794 using char_type = char;
5796 wide_string_input_adapter(BaseInputAdapter base)
5797 : base_adapter(base) {}
5799 typename std::char_traits<char>::int_type get_character() noexcept
5802 if (utf8_bytes_index == utf8_bytes_filled)
5804 fill_buffer<sizeof(WideCharType)>();
5812 JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled);
5813 return utf8_bytes[utf8_bytes_index++];
5817 BaseInputAdapter base_adapter;
5822 wide_string_input_helper<BaseInputAdapter, T>::fill_buffer(base_adapter, utf8_bytes, utf8_bytes_index, utf8_bytes_filled);
5826 std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
5829 std::size_t utf8_bytes_index = 0;
5831 std::size_t utf8_bytes_filled = 0;
5835template<
typename IteratorType,
typename Enable =
void>
5836struct iterator_input_adapter_factory
5838 using iterator_type = IteratorType;
5839 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
5840 using adapter_type = iterator_input_adapter<iterator_type>;
5842 static adapter_type create(IteratorType
first, IteratorType last)
5849struct is_iterator_of_multibyte
5851 using value_type =
typename std::iterator_traits<T>::value_type;
5854 value =
sizeof(value_type) > 1
5858template<
typename IteratorType>
5859struct iterator_input_adapter_factory<IteratorType,
enable_if_t<is_iterator_of_multibyte<IteratorType>::
value>>
5861 using iterator_type = IteratorType;
5862 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
5863 using base_adapter_type = iterator_input_adapter<iterator_type>;
5864 using adapter_type = wide_string_input_adapter<base_adapter_type, char_type>;
5866 static adapter_type create(IteratorType
first, IteratorType last)
5873template<
typename IteratorType>
5874typename iterator_input_adapter_factory<IteratorType>::adapter_type input_adapter(IteratorType
first, IteratorType last)
5876 using factory_type = iterator_input_adapter_factory<IteratorType>;
5877 return factory_type::create(
first, last);
5884namespace container_input_adapter_factory_impl
5890template<
typename ContainerType,
typename Enable =
void>
5893template<
typename ContainerType>
5895 void_t<decltype(begin(
std::declval<ContainerType>()),
end(std::declval<ContainerType>()))>>
5897 using adapter_type =
decltype(input_adapter(begin(std::declval<ContainerType>()),
end(std::declval<ContainerType>())));
5901 return input_adapter(begin(container),
end(container));
5907template<
typename ContainerType>
5908typename container_input_adapter_factory_impl::container_input_adapter_factory<ContainerType>::adapter_type input_adapter(
const ContainerType& container)
5910 return container_input_adapter_factory_impl::container_input_adapter_factory<ContainerType>::create(container);
5915inline file_input_adapter input_adapter(std::FILE* file)
5917 return file_input_adapter(file);
5920inline input_stream_adapter input_adapter(std::istream&
stream)
5922 return input_stream_adapter(
stream);
5925inline input_stream_adapter input_adapter(std::istream&&
stream)
5927 return input_stream_adapter(
stream);
5931using contiguous_bytes_input_adapter =
decltype(input_adapter(std::declval<const char*>(), std::declval<const char*>()));
5934template <
typename CharT,
5935 typename std::enable_if <
5936 std::is_pointer<CharT>::value&&
5937 !std::is_array<CharT>::value&&
5938 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
5939 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
5941contiguous_bytes_input_adapter input_adapter(CharT
b)
5943 auto length = std::strlen(
reinterpret_cast<const char*
>(
b));
5944 const auto* ptr =
reinterpret_cast<const char*
>(
b);
5945 return input_adapter(ptr, ptr +
length);
5948template<
typename T, std::
size_t N>
5949auto input_adapter(T (&
array)[N]) ->
decltype(input_adapter(
array,
array + N))
5957class span_input_adapter
5960 template <
typename CharT,
5961 typename std::enable_if <
5962 std::is_pointer<CharT>::value&&
5963 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
5964 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
5966 span_input_adapter(CharT
b, std::size_t l)
5967 : ia(reinterpret_cast<const char*>(
b), reinterpret_cast<const char*>(
b) + l) {}
5969 template<
class IteratorType,
5970 typename std::enable_if<
5971 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>
::value,
5973 span_input_adapter(IteratorType
first, IteratorType last)
5974 : ia(input_adapter(
first, last)) {}
5976 contiguous_bytes_input_adapter&&
get()
5982 contiguous_bytes_input_adapter ia;
6013template<
typename BasicJsonType>
6016 using number_integer_t =
typename BasicJsonType::number_integer_t;
6017 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
6018 using number_float_t =
typename BasicJsonType::number_float_t;
6019 using string_t =
typename BasicJsonType::string_t;
6020 using binary_t =
typename BasicJsonType::binary_t;
6026 virtual bool null() = 0;
6079 virtual bool start_object(std::size_t elements) = 0;
6087 virtual bool key(string_t&
val) = 0;
6093 virtual bool end_object() = 0;
6101 virtual bool start_array(std::size_t elements) = 0;
6107 virtual bool end_array() = 0;
6116 virtual bool parse_error(std::size_t
position,
6117 const std::string& last_token,
6118 const detail::exception& ex) = 0;
6120 json_sax() =
default;
6121 json_sax(
const json_sax&) =
default;
6122 json_sax(json_sax&&) noexcept = default;
6123 json_sax& operator=(const json_sax&) = default;
6124 json_sax& operator=(json_sax&&) noexcept = default;
6125 virtual ~json_sax() = default;
6144template<
typename BasicJsonType>
6160 : root(
r), allow_exceptions(allow_exceptions_)
6172 handle_value(
nullptr);
6214 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
6218 JSON_THROW(out_of_range::create(408,
concat(
"excessive object size: ", std::to_string(
len)), ref_stack.back()));
6227 object_element = &(ref_stack.back()->m_value.object->operator[](
val));
6233 ref_stack.back()->set_parents();
6234 ref_stack.pop_back();
6240 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
6244 JSON_THROW(out_of_range::create(408,
concat(
"excessive array size: ", std::to_string(
len)), ref_stack.back()));
6252 ref_stack.back()->set_parents();
6253 ref_stack.pop_back();
6257 template<
class Exception>
6259 const Exception& ex)
6262 static_cast<void>(ex);
6263 if (allow_exceptions)
6282 template<
typename Value>
6284 BasicJsonType* handle_value(Value&&
v)
6286 if (ref_stack.empty())
6288 root = BasicJsonType(std::forward<Value>(
v));
6292 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6294 if (ref_stack.back()->is_array())
6296 ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(
v));
6297 return &(ref_stack.back()->m_value.array->back());
6302 *object_element = BasicJsonType(std::forward<Value>(
v));
6303 return object_element;
6307 BasicJsonType&
root;
6309 std::vector<BasicJsonType*> ref_stack {};
6311 BasicJsonType* object_element =
nullptr;
6313 bool errored =
false;
6315 const bool allow_exceptions =
true;
6318template<
typename BasicJsonType>
6332 const bool allow_exceptions_ =
true)
6333 : root(
r), callback(cb), allow_exceptions(allow_exceptions_)
6335 keep_stack.push_back(
true);
6347 handle_value(
nullptr);
6390 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::object_start,
discarded);
6391 keep_stack.push_back(keep);
6393 auto val = handle_value(BasicJsonType::value_t::object,
true);
6394 ref_stack.push_back(
val.second);
6399 JSON_THROW(out_of_range::create(408,
concat(
"excessive object size: ", std::to_string(
len)), ref_stack.back()));
6407 BasicJsonType k = BasicJsonType(
val);
6410 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::key, k);
6411 key_keep_stack.push_back(keep);
6414 if (keep && ref_stack.back())
6416 object_element = &(ref_stack.back()->m_value.object->operator[](
val) =
discarded);
6424 if (ref_stack.back())
6426 if (!callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
6433 ref_stack.back()->set_parents();
6439 ref_stack.pop_back();
6440 keep_stack.pop_back();
6442 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
6445 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
6447 if (it->is_discarded())
6449 ref_stack.back()->erase(it);
6460 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::array_start,
discarded);
6461 keep_stack.push_back(keep);
6463 auto val = handle_value(BasicJsonType::value_t::array,
true);
6464 ref_stack.push_back(
val.second);
6469 JSON_THROW(out_of_range::create(408,
concat(
"excessive array size: ", std::to_string(
len)), ref_stack.back()));
6479 if (ref_stack.back())
6481 keep = callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
6484 ref_stack.back()->set_parents();
6495 ref_stack.pop_back();
6496 keep_stack.pop_back();
6499 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
6501 ref_stack.back()->m_value.array->pop_back();
6507 template<
class Exception>
6509 const Exception& ex)
6512 static_cast<void>(ex);
6513 if (allow_exceptions)
6541 template<
typename Value>
6542 std::pair<bool, BasicJsonType*> handle_value(Value&&
v,
const bool skip_callback =
false)
6548 if (!keep_stack.back())
6550 return {
false,
nullptr};
6554 auto value = BasicJsonType(std::forward<Value>(
v));
6557 const bool keep = skip_callback || callback(
static_cast<int>(ref_stack.size()), parse_event_t::value,
value);
6562 return {
false,
nullptr};
6565 if (ref_stack.empty())
6568 return {
true, &
root};
6573 if (!ref_stack.back())
6575 return {
false,
nullptr};
6579 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6582 if (ref_stack.back()->is_array())
6585 return {
true, &(ref_stack.back()->m_value.array->back())};
6592 const bool store_element = key_keep_stack.back();
6593 key_keep_stack.pop_back();
6597 return {
false,
nullptr};
6602 return {
true, object_element};
6606 BasicJsonType&
root;
6608 std::vector<BasicJsonType*> ref_stack {};
6610 std::vector<bool> keep_stack {};
6612 std::vector<bool> key_keep_stack {};
6614 BasicJsonType* object_element =
nullptr;
6616 bool errored =
false;
6618 const parser_callback_t callback =
nullptr;
6620 const bool allow_exceptions =
true;
6622 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
6625template<
typename BasicJsonType>
6712#include <initializer_list>
6732template<
typename BasicJsonType>
6766 return "<uninitialized>";
6768 return "true literal";
6770 return "false literal";
6772 return "null literal";
6774 return "string literal";
6778 return "number literal";
6792 return "<parse error>";
6794 return "end of input";
6796 return "'[', '{', or a literal";
6799 return "unknown token";
6809template<
typename BasicJsonType,
typename InputAdapterType>
6812 using number_integer_t =
typename BasicJsonType::number_integer_t;
6813 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
6814 using number_float_t =
typename BasicJsonType::number_float_t;
6815 using string_t =
typename BasicJsonType::string_t;
6816 using char_type =
typename InputAdapterType::char_type;
6817 using char_int_type =
typename std::char_traits<char_type>::int_type;
6822 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
6823 : ia(
std::move(adapter))
6824 , ignore_comments(ignore_comments_)
6825 , decimal_point_char(static_cast<char_int_type>(get_decimal_point()))
6842 static char get_decimal_point() noexcept
6844 const auto* loc = localeconv();
6846 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
6874 const auto factors = { 12u, 8u, 4u, 0
u };
6875 for (
const auto factor : factors)
6879 if (current >=
'0' && current <=
'9')
6881 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x30u) << factor);
6883 else if (current >=
'A' && current <=
'F')
6885 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x37u) << factor);
6887 else if (current >=
'a' && current <=
'f')
6889 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x57u) << factor);
6897 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
6916 bool next_byte_in_range(std::initializer_list<char_int_type> ranges)
6918 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
6930 error_message =
"invalid string: ill-formed UTF-8 byte";
6967 case std::char_traits<char_type>::eof():
6969 error_message =
"invalid string: missing closing quote";
6970 return token_type::parse_error;
6976 return token_type::value_string;
7020 const int codepoint1 = get_codepoint();
7021 int codepoint = codepoint1;
7025 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7026 return token_type::parse_error;
7030 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
7035 const int codepoint2 = get_codepoint();
7039 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7040 return token_type::parse_error;
7047 codepoint =
static_cast<int>(
7049 (
static_cast<unsigned int>(codepoint1) << 10u)
7051 +
static_cast<unsigned int>(codepoint2)
7059 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7060 return token_type::parse_error;
7065 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7066 return token_type::parse_error;
7073 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
7074 return token_type::parse_error;
7079 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7082 if (codepoint < 0x80)
7085 add(
static_cast<char_int_type
>(codepoint));
7087 else if (codepoint <= 0x7FF)
7090 add(
static_cast<char_int_type
>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
7091 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7093 else if (codepoint <= 0xFFFF)
7096 add(
static_cast<char_int_type
>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
7097 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7098 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7103 add(
static_cast<char_int_type
>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
7104 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
7105 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7106 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7114 error_message =
"invalid string: forbidden character after backslash";
7115 return token_type::parse_error;
7124 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
7125 return token_type::parse_error;
7130 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
7131 return token_type::parse_error;
7136 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
7137 return token_type::parse_error;
7142 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
7143 return token_type::parse_error;
7148 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
7149 return token_type::parse_error;
7154 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
7155 return token_type::parse_error;
7160 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
7161 return token_type::parse_error;
7166 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
7167 return token_type::parse_error;
7172 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
7173 return token_type::parse_error;
7178 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
7179 return token_type::parse_error;
7184 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
7185 return token_type::parse_error;
7190 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
7191 return token_type::parse_error;
7196 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
7197 return token_type::parse_error;
7202 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
7203 return token_type::parse_error;
7208 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
7209 return token_type::parse_error;
7214 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
7215 return token_type::parse_error;
7220 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
7221 return token_type::parse_error;
7226 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
7227 return token_type::parse_error;
7232 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
7233 return token_type::parse_error;
7238 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
7239 return token_type::parse_error;
7244 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
7245 return token_type::parse_error;
7250 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
7251 return token_type::parse_error;
7256 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
7257 return token_type::parse_error;
7262 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
7263 return token_type::parse_error;
7268 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
7269 return token_type::parse_error;
7274 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
7275 return token_type::parse_error;
7280 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
7281 return token_type::parse_error;
7286 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
7287 return token_type::parse_error;
7292 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
7293 return token_type::parse_error;
7298 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7299 return token_type::parse_error;
7304 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7305 return token_type::parse_error;
7310 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7311 return token_type::parse_error;
7448 return token_type::parse_error;
7458 return token_type::parse_error;
7482 return token_type::parse_error;
7492 return token_type::parse_error;
7502 return token_type::parse_error;
7514 return token_type::parse_error;
7524 return token_type::parse_error;
7532 error_message =
"invalid string: ill-formed UTF-8 byte";
7533 return token_type::parse_error;
7556 case std::char_traits<char_type>::eof():
7573 case std::char_traits<char_type>::eof():
7576 error_message =
"invalid comment; missing closing '*/'";
7604 error_message =
"invalid comment; expecting '/' or '*' after '/'";
7611 static
void strtof(
float&
f, const
char* str,
char** endptr) noexcept
7613 f = std::strtof(str, endptr);
7617 static
void strtof(
double&
f, const
char* str,
char** endptr) noexcept
7619 f = std::strtod(str, endptr);
7623 static
void strtof(
long double&
f, const
char* str,
char** endptr) noexcept
7625 f = std::strtold(str, endptr);
7668 token_type scan_number()
7675 token_type number_type = token_type::value_unsigned;
7683 goto scan_number_minus;
7689 goto scan_number_zero;
7703 goto scan_number_any1;
7713 number_type = token_type::value_integer;
7719 goto scan_number_zero;
7733 goto scan_number_any1;
7738 error_message =
"invalid number; expected digit after '-'";
7739 return token_type::parse_error;
7749 add(decimal_point_char);
7750 goto scan_number_decimal1;
7757 goto scan_number_exponent;
7761 goto scan_number_done;
7780 goto scan_number_any1;
7785 add(decimal_point_char);
7786 goto scan_number_decimal1;
7793 goto scan_number_exponent;
7797 goto scan_number_done;
7800scan_number_decimal1:
7802 number_type = token_type::value_float;
7817 goto scan_number_decimal2;
7822 error_message =
"invalid number; expected digit after '.'";
7823 return token_type::parse_error;
7827scan_number_decimal2:
7843 goto scan_number_decimal2;
7850 goto scan_number_exponent;
7854 goto scan_number_done;
7857scan_number_exponent:
7859 number_type = token_type::value_float;
7866 goto scan_number_sign;
7881 goto scan_number_any2;
7887 "invalid number; expected '+', '-', or digit after exponent";
7888 return token_type::parse_error;
7908 goto scan_number_any2;
7913 error_message =
"invalid number; expected digit after exponent sign";
7914 return token_type::parse_error;
7934 goto scan_number_any2;
7938 goto scan_number_done;
7946 char* endptr =
nullptr;
7950 if (number_type == token_type::value_unsigned)
7952 const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
7955 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
7959 value_unsigned =
static_cast<number_unsigned_t
>(
x);
7960 if (value_unsigned ==
x)
7962 return token_type::value_unsigned;
7966 else if (number_type == token_type::value_integer)
7968 const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
7971 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
7975 value_integer =
static_cast<number_integer_t
>(
x);
7976 if (value_integer ==
x)
7978 return token_type::value_integer;
7985 strtof(value_float, token_buffer.data(), &endptr);
7988 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
7990 return token_type::value_float;
7999 token_type scan_literal(const char_type* literal_text, const
std::
size_t length,
8000 token_type return_type)
8002 JSON_ASSERT(std::char_traits<char_type>::to_char_type(current) == literal_text[0]);
8003 for (std::size_t i = 1; i <
length; ++i)
8007 error_message =
"invalid literal";
8008 return token_type::parse_error;
8019 void reset() noexcept
8021 token_buffer.clear();
8022 token_string.clear();
8023 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
8039 ++
position.chars_read_current_line;
8048 current = ia.get_character();
8053 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
8056 if (current ==
'\n')
8059 position.chars_read_current_line = 0;
8080 if (
position.chars_read_current_line == 0)
8089 --
position.chars_read_current_line;
8095 token_string.pop_back();
8100 void add(char_int_type c)
8102 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
8113 return value_integer;
8119 return value_unsigned;
8131 return token_buffer;
8151 for (
const auto c : token_string)
8153 if (
static_cast<unsigned char>(c) <=
'\x1F')
8156 std::array<char, 9> cs{{}};
8157 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
8163 result.push_back(
static_cast<std::string::value_type
>(c));
8174 return error_message;
8190 return get() == 0xBB &&
get() == 0xBF;
8205 while (current ==
' ' || current ==
'\t' || current ==
'\n' || current ==
'\r');
8211 if (
position.chars_read_total == 0 && !skip_bom())
8213 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
8214 return token_type::parse_error;
8221 while (ignore_comments && current ==
'/')
8223 if (!scan_comment())
8225 return token_type::parse_error;
8236 return token_type::begin_array;
8238 return token_type::end_array;
8240 return token_type::begin_object;
8242 return token_type::end_object;
8244 return token_type::name_separator;
8246 return token_type::value_separator;
8251 std::array<char_type, 4> true_literal = {{
static_cast<char_type
>(
't'),
static_cast<char_type
>(
'r'),
static_cast<char_type
>(
'u'),
static_cast<char_type
>(
'e')}};
8252 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
8256 std::array<char_type, 5> false_literal = {{
static_cast<char_type
>(
'f'),
static_cast<char_type
>(
'a'),
static_cast<char_type
>(
'l'),
static_cast<char_type
>(
's'),
static_cast<char_type
>(
'e')}};
8257 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
8261 std::array<char_type, 4> null_literal = {{
static_cast<char_type
>(
'n'),
static_cast<char_type
>(
'u'),
static_cast<char_type
>(
'l'),
static_cast<char_type
>(
'l')}};
8262 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
8267 return scan_string();
8281 return scan_number();
8286 case std::char_traits<char_type>::eof():
8287 return token_type::end_of_input;
8291 error_message =
"invalid literal";
8292 return token_type::parse_error;
8298 InputAdapterType ia;
8301 const bool ignore_comments =
false;
8304 char_int_type current = std::char_traits<char_type>::eof();
8307 bool next_unget =
false;
8313 std::vector<char_type> token_string {};
8316 string_t token_buffer {};
8319 const char* error_message =
"";
8322 number_integer_t value_integer = 0;
8323 number_unsigned_t value_unsigned = 0;
8324 number_float_t value_float = 0;
8327 const char_int_type decimal_point_char =
'.';
8351using null_function_t =
decltype(std::declval<T&>().null());
8354using boolean_function_t =
8355 decltype(std::declval<T&>().boolean(std::declval<bool>()));
8357template<
typename T,
typename Integer>
8358using number_integer_function_t =
8359 decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
8361template<
typename T,
typename Un
signed>
8362using number_unsigned_function_t =
8363 decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
8365template<
typename T,
typename Float,
typename String>
8366using number_float_function_t =
decltype(std::declval<T&>().number_float(
8367 std::declval<Float>(), std::declval<const String&>()));
8369template<
typename T,
typename String>
8370using string_function_t =
8371 decltype(std::declval<T&>().string(std::declval<String&>()));
8373template<
typename T,
typename Binary>
8374using binary_function_t =
8375 decltype(std::declval<T&>().binary(std::declval<Binary&>()));
8378using start_object_function_t =
8379 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
8381template<
typename T,
typename String>
8382using key_function_t =
8383 decltype(std::declval<T&>().key(std::declval<String&>()));
8386using end_object_function_t =
decltype(std::declval<T&>().end_object());
8389using start_array_function_t =
8390 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
8393using end_array_function_t =
decltype(std::declval<T&>().end_array());
8395template<
typename T,
typename Exception>
8396using parse_error_function_t =
decltype(std::declval<T&>().parse_error(
8397 std::declval<std::size_t>(), std::declval<const std::string&>(),
8398 std::declval<const Exception&>()));
8400template<
typename SAX,
typename BasicJsonType>
8404 static_assert(is_basic_json<BasicJsonType>::value,
8405 "BasicJsonType must be of type basic_json<...>");
8407 using number_integer_t =
typename BasicJsonType::number_integer_t;
8408 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
8409 using number_float_t =
typename BasicJsonType::number_float_t;
8410 using string_t =
typename BasicJsonType::string_t;
8411 using binary_t =
typename BasicJsonType::binary_t;
8412 using exception_t =
typename BasicJsonType::exception;
8415 static constexpr bool value =
8416 is_detected_exact<bool, null_function_t, SAX>::value &&
8417 is_detected_exact<bool, boolean_function_t, SAX>::value &&
8418 is_detected_exact<bool, number_integer_function_t, SAX, number_integer_t>::value &&
8419 is_detected_exact<bool, number_unsigned_function_t, SAX, number_unsigned_t>::value &&
8420 is_detected_exact<bool, number_float_function_t, SAX, number_float_t, string_t>::value &&
8421 is_detected_exact<bool, string_function_t, SAX, string_t>::value &&
8422 is_detected_exact<bool, binary_function_t, SAX, binary_t>::value &&
8423 is_detected_exact<bool, start_object_function_t, SAX>::value &&
8424 is_detected_exact<bool, key_function_t, SAX, string_t>::value &&
8425 is_detected_exact<bool, end_object_function_t, SAX>::value &&
8426 is_detected_exact<bool, start_array_function_t, SAX>::value &&
8427 is_detected_exact<bool, end_array_function_t, SAX>::value &&
8428 is_detected_exact<bool, parse_error_function_t, SAX, exception_t>::value;
8431template<
typename SAX,
typename BasicJsonType>
8432struct is_sax_static_asserts
8435 static_assert(is_basic_json<BasicJsonType>::value,
8436 "BasicJsonType must be of type basic_json<...>");
8438 using number_integer_t =
typename BasicJsonType::number_integer_t;
8439 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
8440 using number_float_t =
typename BasicJsonType::number_float_t;
8441 using string_t =
typename BasicJsonType::string_t;
8442 using binary_t =
typename BasicJsonType::binary_t;
8443 using exception_t =
typename BasicJsonType::exception;
8446 static_assert(is_detected_exact<bool, null_function_t, SAX>::value,
8447 "Missing/invalid function: bool null()");
8448 static_assert(is_detected_exact<bool, boolean_function_t, SAX>::value,
8449 "Missing/invalid function: bool boolean(bool)");
8450 static_assert(is_detected_exact<bool, boolean_function_t, SAX>::value,
8451 "Missing/invalid function: bool boolean(bool)");
8455 "Missing/invalid function: bool number_integer(number_integer_t)");
8459 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
8461 number_float_t, string_t>
::value,
8462 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
8464 is_detected_exact<bool, string_function_t, SAX, string_t>::value,
8465 "Missing/invalid function: bool string(string_t&)");
8467 is_detected_exact<bool, binary_function_t, SAX, binary_t>::value,
8468 "Missing/invalid function: bool binary(binary_t&)");
8469 static_assert(is_detected_exact<bool, start_object_function_t, SAX>::value,
8470 "Missing/invalid function: bool start_object(std::size_t)");
8471 static_assert(is_detected_exact<bool, key_function_t, SAX, string_t>::value,
8472 "Missing/invalid function: bool key(string_t&)");
8473 static_assert(is_detected_exact<bool, end_object_function_t, SAX>::value,
8474 "Missing/invalid function: bool end_object()");
8475 static_assert(is_detected_exact<bool, start_array_function_t, SAX>::value,
8476 "Missing/invalid function: bool start_array(std::size_t)");
8477 static_assert(is_detected_exact<bool, end_array_function_t, SAX>::value,
8478 "Missing/invalid function: bool end_array()");
8480 is_detected_exact<bool, parse_error_function_t, SAX, exception_t>::value,
8481 "Missing/invalid function: bool parse_error(std::size_t, const "
8482 "std::string&, const exception&)");
8514static inline bool little_endianness(
int num = 1) noexcept
8516 return *
reinterpret_cast<char*
>(&
num) == 1;
8527template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType>>
8530 using number_integer_t =
typename BasicJsonType::number_integer_t;
8531 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
8532 using number_float_t =
typename BasicJsonType::number_float_t;
8533 using string_t =
typename BasicJsonType::string_t;
8534 using binary_t =
typename BasicJsonType::binary_t;
8535 using json_sax_t = SAX;
8536 using char_type =
typename InputAdapterType::char_type;
8537 using char_int_type =
typename std::char_traits<char_type>::int_type;
8547 (
void)detail::is_sax_static_asserts<SAX, BasicJsonType> {};
8576 case input_format_t::bson:
8577 result = parse_bson_internal();
8580 case input_format_t::cbor:
8581 result = parse_cbor_internal(
true, tag_handler);
8584 case input_format_t::msgpack:
8585 result = parse_msgpack_internal();
8588 case input_format_t::ubjson:
8589 case input_format_t::bjdata:
8590 result = parse_ubjson_internal();
8593 case input_format_t::json:
8601 if (input_format == input_format_t::ubjson || input_format == input_format_t::bjdata)
8612 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(110, chars_read,
8613 exception_message(input_format,
concat(
"expected end of input; last byte: 0x", get_token_string()),
"value"),
nullptr));
8629 bool parse_bson_internal()
8631 std::int32_t document_size{};
8632 get_number<std::int32_t, true>(input_format_t::bson, document_size);
8644 return sax->end_object();
8654 bool get_bson_cstr(string_t&
result)
8656 auto out = std::back_inserter(
result);
8664 if (current == 0x00)
8668 *out++ =
static_cast<typename string_t::value_type
>(current);
8683 template<
typename NumberType>
8684 bool get_bson_string(
const NumberType
len, string_t&
result)
8688 auto last_token = get_token_string();
8690 exception_message(input_format_t::bson,
concat(
"string length must be at least 1, is ", std::to_string(
len)),
"string"),
nullptr));
8693 return get_string(input_format_t::bson,
len -
static_cast<NumberType
>(1),
result) &&
get() != std::char_traits<char_type>::eof();
8705 template<
typename NumberType>
8706 bool get_bson_binary(
const NumberType
len, binary_t&
result)
8710 auto last_token = get_token_string();
8712 exception_message(input_format_t::bson,
concat(
"byte array length cannot be negative, is ", std::to_string(
len)),
"binary"),
nullptr));
8716 std::uint8_t subtype{};
8717 get_number<std::uint8_t>(input_format_t::bson, subtype);
8718 result.set_subtype(subtype);
8720 return get_binary(input_format_t::bson,
len,
result);
8733 bool parse_bson_element_internal(
const char_int_type element_type,
8734 const std::size_t element_type_parse_position)
8736 switch (element_type)
8741 return get_number<double, true>(input_format_t::bson, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
8748 return get_number<std::int32_t, true>(input_format_t::bson,
len) && get_bson_string(
len,
value) && sax->string(
value);
8753 return parse_bson_internal();
8758 return parse_bson_array();
8765 return get_number<std::int32_t, true>(input_format_t::bson,
len) && get_bson_binary(
len,
value) && sax->binary(
value);
8770 return sax->boolean(
get() != 0);
8780 std::int32_t
value{};
8781 return get_number<std::int32_t, true>(input_format_t::bson,
value) && sax->number_integer(
value);
8786 std::int64_t
value{};
8787 return get_number<std::int64_t, true>(input_format_t::bson,
value) && sax->number_integer(
value);
8792 std::array<char, 3> cr{{}};
8793 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
8794 std::string cr_str{cr.data()};
8795 return sax->parse_error(element_type_parse_position, cr_str,
8813 bool parse_bson_element_list(
const bool is_array)
8817 while (
auto element_type =
get())
8824 const std::size_t element_type_parse_position = chars_read;
8835 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
8851 bool parse_bson_array()
8853 std::int32_t document_size{};
8854 get_number<std::int32_t, true>(input_format_t::bson, document_size);
8866 return sax->end_array();
8881 bool parse_cbor_internal(
const bool get_char,
8884 switch (get_char ?
get() : current)
8887 case std::char_traits<char_type>::eof():
8888 return unexpect_eof(input_format_t::cbor,
"value");
8915 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
8919 std::uint8_t number{};
8920 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
8925 std::uint16_t number{};
8926 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
8931 std::uint32_t number{};
8932 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
8937 std::uint64_t number{};
8938 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
8966 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 - current));
8970 std::uint8_t number{};
8971 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
8976 std::uint16_t number{};
8977 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
8982 std::uint32_t number{};
8983 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
8988 std::uint64_t number{};
8989 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1)
8990 -
static_cast<number_integer_t
>(number));
9025 return get_cbor_binary(
b) && sax->binary(
b);
9060 return get_cbor_string(s) && sax->string(s);
9088 return get_cbor_array(
static_cast<std::size_t
>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9093 return get_number(input_format_t::cbor,
len) && get_cbor_array(
static_cast<std::size_t
>(
len), tag_handler);
9098 std::uint16_t
len{};
9099 return get_number(input_format_t::cbor,
len) && get_cbor_array(
static_cast<std::size_t
>(
len), tag_handler);
9104 std::uint32_t
len{};
9105 return get_number(input_format_t::cbor,
len) && get_cbor_array(
static_cast<std::size_t
>(
len), tag_handler);
9110 std::uint64_t
len{};
9111 return get_number(input_format_t::cbor,
len) && get_cbor_array(detail::conditional_static_cast<std::size_t>(
len), tag_handler);
9115 return get_cbor_array(
static_cast<std::size_t
>(-1), tag_handler);
9142 return get_cbor_object(
static_cast<std::size_t
>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9147 return get_number(input_format_t::cbor,
len) && get_cbor_object(
static_cast<std::size_t
>(
len), tag_handler);
9152 std::uint16_t
len{};
9153 return get_number(input_format_t::cbor,
len) && get_cbor_object(
static_cast<std::size_t
>(
len), tag_handler);
9158 std::uint32_t
len{};
9159 return get_number(input_format_t::cbor,
len) && get_cbor_object(
static_cast<std::size_t
>(
len), tag_handler);
9164 std::uint64_t
len{};
9165 return get_number(input_format_t::cbor,
len) && get_cbor_object(detail::conditional_static_cast<std::size_t>(
len), tag_handler);
9169 return get_cbor_object(
static_cast<std::size_t
>(-1), tag_handler);
9191 switch (tag_handler)
9195 auto last_token = get_token_string();
9197 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
9207 std::uint8_t subtype_to_ignore{};
9208 get_number(input_format_t::cbor, subtype_to_ignore);
9213 std::uint16_t subtype_to_ignore{};
9214 get_number(input_format_t::cbor, subtype_to_ignore);
9219 std::uint32_t subtype_to_ignore{};
9220 get_number(input_format_t::cbor, subtype_to_ignore);
9225 std::uint64_t subtype_to_ignore{};
9226 get_number(input_format_t::cbor, subtype_to_ignore);
9232 return parse_cbor_internal(
true, tag_handler);
9243 std::uint8_t subtype{};
9244 get_number(input_format_t::cbor, subtype);
9245 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9250 std::uint16_t subtype{};
9251 get_number(input_format_t::cbor, subtype);
9252 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9257 std::uint32_t subtype{};
9258 get_number(input_format_t::cbor, subtype);
9259 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9264 std::uint64_t subtype{};
9265 get_number(input_format_t::cbor, subtype);
9266 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9270 return parse_cbor_internal(
true, tag_handler);
9273 return get_cbor_binary(
b) && sax->binary(
b);
9283 return sax->boolean(
false);
9286 return sax->boolean(
true);
9293 const auto byte1_raw =
get();
9298 const auto byte2_raw =
get();
9304 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
9305 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
9315 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
9316 const double val = [&half]
9318 const int exp = (half >> 10u) & 0x1Fu;
9319 const unsigned int mant = half & 0x3FFu;
9325 return std::ldexp(mant, -24);
9328 ? std::numeric_limits<double>::infinity()
9329 :
std::numeric_limits<double>::quiet_NaN();
9331 return std::ldexp(mant + 1024,
exp - 25);
9334 return sax->number_float((half & 0x8000u) != 0
9335 ?
static_cast<number_float_t
>(-
val)
9336 : static_cast<number_float_t>(
val),
"");
9342 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9348 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9353 auto last_token = get_token_string();
9355 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
9371 bool get_cbor_string(string_t&
result)
9406 return get_string(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu,
result);
9412 return get_number(input_format_t::cbor,
len) && get_string(input_format_t::cbor,
len,
result);
9417 std::uint16_t
len{};
9418 return get_number(input_format_t::cbor,
len) && get_string(input_format_t::cbor,
len,
result);
9423 std::uint32_t
len{};
9424 return get_number(input_format_t::cbor,
len) && get_string(input_format_t::cbor,
len,
result);
9429 std::uint64_t
len{};
9430 return get_number(input_format_t::cbor,
len) && get_string(input_format_t::cbor,
len,
result);
9435 while (
get() != 0xFF)
9438 if (!get_cbor_string(chunk))
9449 auto last_token = get_token_string();
9451 exception_message(input_format_t::cbor,
concat(
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token),
"string"),
nullptr));
9467 bool get_cbor_binary(binary_t&
result)
9502 return get_binary(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu,
result);
9508 return get_number(input_format_t::cbor,
len) &&
9509 get_binary(input_format_t::cbor,
len,
result);
9514 std::uint16_t
len{};
9515 return get_number(input_format_t::cbor,
len) &&
9516 get_binary(input_format_t::cbor,
len,
result);
9521 std::uint32_t
len{};
9522 return get_number(input_format_t::cbor,
len) &&
9523 get_binary(input_format_t::cbor,
len,
result);
9528 std::uint64_t
len{};
9529 return get_number(input_format_t::cbor,
len) &&
9530 get_binary(input_format_t::cbor,
len,
result);
9535 while (
get() != 0xFF)
9538 if (!get_cbor_binary(chunk))
9549 auto last_token = get_token_string();
9551 exception_message(input_format_t::cbor,
concat(
"expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x", last_token),
"binary"),
nullptr));
9562 bool get_cbor_array(
const std::size_t
len,
9570 if (
len !=
static_cast<std::size_t
>(-1))
9572 for (std::size_t i = 0; i <
len; ++i)
9582 while (
get() != 0xFF)
9591 return sax->end_array();
9600 bool get_cbor_object(
const std::size_t
len,
9611 if (
len !=
static_cast<std::size_t
>(-1))
9613 for (std::size_t i = 0; i <
len; ++i)
9630 while (
get() != 0xFF)
9646 return sax->end_object();
9656 bool parse_msgpack_internal()
9661 case std::char_traits<char_type>::eof():
9662 return unexpect_eof(input_format_t::msgpack,
"value");
9793 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
9812 return get_msgpack_object(
static_cast<std::size_t
>(
static_cast<unsigned int>(current) & 0x0Fu));
9831 return get_msgpack_array(
static_cast<std::size_t
>(
static_cast<unsigned int>(current) & 0x0Fu));
9871 return get_msgpack_string(s) && sax->string(s);
9878 return sax->boolean(
false);
9881 return sax->boolean(
true);
9896 return get_msgpack_binary(
b) && sax->binary(
b);
9902 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9908 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9913 std::uint8_t number{};
9914 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
9919 std::uint16_t number{};
9920 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
9925 std::uint32_t number{};
9926 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
9931 std::uint64_t number{};
9932 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
9937 std::int8_t number{};
9938 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
9943 std::int16_t number{};
9944 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
9949 std::int32_t number{};
9950 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
9955 std::int64_t number{};
9956 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
9961 std::uint16_t
len{};
9962 return get_number(input_format_t::msgpack,
len) && get_msgpack_array(
static_cast<std::size_t
>(
len));
9967 std::uint32_t
len{};
9968 return get_number(input_format_t::msgpack,
len) && get_msgpack_array(
static_cast<std::size_t
>(
len));
9973 std::uint16_t
len{};
9974 return get_number(input_format_t::msgpack,
len) && get_msgpack_object(
static_cast<std::size_t
>(
len));
9979 std::uint32_t
len{};
9980 return get_number(input_format_t::msgpack,
len) && get_msgpack_object(
static_cast<std::size_t
>(
len));
10016 return sax->number_integer(
static_cast<std::int8_t
>(current));
10020 auto last_token = get_token_string();
10022 exception_message(input_format_t::msgpack,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10037 bool get_msgpack_string(string_t&
result)
10080 return get_string(input_format_t::msgpack,
static_cast<unsigned int>(current) & 0x1Fu,
result);
10085 std::uint8_t
len{};
10086 return get_number(input_format_t::msgpack,
len) && get_string(input_format_t::msgpack,
len,
result);
10091 std::uint16_t
len{};
10092 return get_number(input_format_t::msgpack,
len) && get_string(input_format_t::msgpack,
len,
result);
10097 std::uint32_t
len{};
10098 return get_number(input_format_t::msgpack,
len) && get_string(input_format_t::msgpack,
len,
result);
10103 auto last_token = get_token_string();
10105 exception_message(input_format_t::msgpack,
concat(
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token),
"string"),
nullptr));
10120 bool get_msgpack_binary(binary_t&
result)
10123 auto assign_and_return_true = [&
result](std::int8_t subtype)
10125 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
10133 std::uint8_t
len{};
10134 return get_number(input_format_t::msgpack,
len) &&
10135 get_binary(input_format_t::msgpack,
len,
result);
10140 std::uint16_t
len{};
10141 return get_number(input_format_t::msgpack,
len) &&
10142 get_binary(input_format_t::msgpack,
len,
result);
10147 std::uint32_t
len{};
10148 return get_number(input_format_t::msgpack,
len) &&
10149 get_binary(input_format_t::msgpack,
len,
result);
10154 std::uint8_t
len{};
10155 std::int8_t subtype{};
10156 return get_number(input_format_t::msgpack,
len) &&
10157 get_number(input_format_t::msgpack, subtype) &&
10158 get_binary(input_format_t::msgpack,
len,
result) &&
10159 assign_and_return_true(subtype);
10164 std::uint16_t
len{};
10165 std::int8_t subtype{};
10166 return get_number(input_format_t::msgpack,
len) &&
10167 get_number(input_format_t::msgpack, subtype) &&
10168 get_binary(input_format_t::msgpack,
len,
result) &&
10169 assign_and_return_true(subtype);
10174 std::uint32_t
len{};
10175 std::int8_t subtype{};
10176 return get_number(input_format_t::msgpack,
len) &&
10177 get_number(input_format_t::msgpack, subtype) &&
10178 get_binary(input_format_t::msgpack,
len,
result) &&
10179 assign_and_return_true(subtype);
10184 std::int8_t subtype{};
10185 return get_number(input_format_t::msgpack, subtype) &&
10186 get_binary(input_format_t::msgpack, 1,
result) &&
10187 assign_and_return_true(subtype);
10192 std::int8_t subtype{};
10193 return get_number(input_format_t::msgpack, subtype) &&
10194 get_binary(input_format_t::msgpack, 2,
result) &&
10195 assign_and_return_true(subtype);
10200 std::int8_t subtype{};
10201 return get_number(input_format_t::msgpack, subtype) &&
10202 get_binary(input_format_t::msgpack, 4,
result) &&
10203 assign_and_return_true(subtype);
10208 std::int8_t subtype{};
10209 return get_number(input_format_t::msgpack, subtype) &&
10210 get_binary(input_format_t::msgpack, 8,
result) &&
10211 assign_and_return_true(subtype);
10216 std::int8_t subtype{};
10217 return get_number(input_format_t::msgpack, subtype) &&
10218 get_binary(input_format_t::msgpack, 16,
result) &&
10219 assign_and_return_true(subtype);
10231 bool get_msgpack_array(
const std::size_t
len)
10238 for (std::size_t i = 0; i <
len; ++i)
10246 return sax->end_array();
10253 bool get_msgpack_object(
const std::size_t
len)
10261 for (std::size_t i = 0; i <
len; ++i)
10276 return sax->end_object();
10290 bool parse_ubjson_internal(
const bool get_char =
true)
10292 return get_ubjson_value(get_char ? get_ignore_noop() : current);
10309 bool get_ubjson_string(string_t&
result,
const bool get_char =
true)
10325 std::uint8_t
len{};
10326 return get_number(input_format,
len) && get_string(input_format,
len,
result);
10332 return get_number(input_format,
len) && get_string(input_format,
len,
result);
10337 std::int16_t
len{};
10338 return get_number(input_format,
len) && get_string(input_format,
len,
result);
10343 std::int32_t
len{};
10344 return get_number(input_format,
len) && get_string(input_format,
len,
result);
10349 std::int64_t
len{};
10350 return get_number(input_format,
len) && get_string(input_format,
len,
result);
10355 if (input_format != input_format_t::bjdata)
10359 std::uint16_t
len{};
10360 return get_number(input_format,
len) && get_string(input_format,
len,
result);
10365 if (input_format != input_format_t::bjdata)
10369 std::uint32_t
len{};
10370 return get_number(input_format,
len) && get_string(input_format,
len,
result);
10375 if (input_format != input_format_t::bjdata)
10379 std::uint64_t
len{};
10380 return get_number(input_format,
len) && get_string(input_format,
len,
result);
10386 auto last_token = get_token_string();
10389 if (input_format != input_format_t::bjdata)
10391 message =
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token;
10395 message =
"expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token;
10397 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format,
message,
"string"),
nullptr));
10404 bool get_ubjson_ndarray_size(std::vector<size_t>& dim)
10406 std::pair<std::size_t, char_int_type> size_and_type;
10414 if (size_and_type.first != string_t::npos)
10416 if (size_and_type.second != 0)
10418 if (size_and_type.second !=
'N')
10420 for (std::size_t i = 0; i < size_and_type.first; ++i)
10426 dim.push_back(dimlen);
10432 for (std::size_t i = 0; i < size_and_type.first; ++i)
10438 dim.push_back(dimlen);
10444 while (current !=
']')
10450 dim.push_back(dimlen);
10461 bool get_ubjson_size_value(std::size_t&
result, char_int_type prefix = 0)
10465 prefix = get_ignore_noop();
10472 std::uint8_t number{};
10477 result =
static_cast<std::size_t
>(number);
10483 std::int8_t number{};
10488 result =
static_cast<std::size_t
>(number);
10494 std::int16_t number{};
10499 result =
static_cast<std::size_t
>(number);
10505 std::int32_t number{};
10510 result =
static_cast<std::size_t
>(number);
10516 std::int64_t number{};
10521 result =
static_cast<std::size_t
>(number);
10527 if (input_format != input_format_t::bjdata)
10531 std::uint16_t number{};
10536 result =
static_cast<std::size_t
>(number);
10542 if (input_format != input_format_t::bjdata)
10546 std::uint32_t number{};
10551 result =
static_cast<std::size_t
>(number);
10557 if (input_format != input_format_t::bjdata)
10561 std::uint64_t number{};
10566 result = detail::conditional_static_cast<std::size_t>(number);
10572 if (input_format != input_format_t::bjdata)
10576 std::vector<size_t> dim;
10581 if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1))
10583 result = dim.at(dim.size() - 1);
10588 string_t key =
"_ArraySize_";
10589 if (
JSON_HEDLEY_UNLIKELY(!sax->start_object(3) || !sax->key(key) || !sax->start_array(dim.size())))
10603 return sax->end_array();
10612 auto last_token = get_token_string();
10615 if (input_format != input_format_t::bjdata)
10617 message =
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token;
10621 message =
"expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token;
10623 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format,
message,
"size"),
nullptr));
10636 bool get_ubjson_size_type(std::pair<std::size_t, char_int_type>&
result)
10638 result.first = string_t::npos;
10643 if (current ==
'$')
10645 std::vector<char_int_type> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
10648 if (
JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format,
"type") || (input_format == input_format_t::bjdata &&
std::find(bjdx.begin(), bjdx.end(),
result.second) != bjdx.end() )))
10660 auto last_token = get_token_string();
10662 exception_message(input_format,
concat(
"expected '#' after type information; last byte: 0x", last_token),
"size"),
nullptr));
10665 return get_ubjson_size_value(
result.first);
10668 if (current ==
'#')
10670 return get_ubjson_size_value(
result.first);
10680 bool get_ubjson_value(
const char_int_type prefix)
10684 case std::char_traits<char_type>::eof():
10685 return unexpect_eof(input_format,
"value");
10688 return sax->boolean(
true);
10690 return sax->boolean(
false);
10693 return sax->null();
10697 std::uint8_t number{};
10698 return get_number(input_format, number) && sax->number_unsigned(number);
10703 std::int8_t number{};
10704 return get_number(input_format, number) && sax->number_integer(number);
10709 std::int16_t number{};
10710 return get_number(input_format, number) && sax->number_integer(number);
10715 std::int32_t number{};
10716 return get_number(input_format, number) && sax->number_integer(number);
10721 std::int64_t number{};
10722 return get_number(input_format, number) && sax->number_integer(number);
10727 if (input_format != input_format_t::bjdata)
10731 std::uint16_t number{};
10732 return get_number(input_format, number) && sax->number_unsigned(number);
10737 if (input_format != input_format_t::bjdata)
10741 std::uint32_t number{};
10742 return get_number(input_format, number) && sax->number_unsigned(number);
10747 if (input_format != input_format_t::bjdata)
10751 std::uint64_t number{};
10752 return get_number(input_format, number) && sax->number_unsigned(number);
10757 if (input_format != input_format_t::bjdata)
10761 const auto byte1_raw =
get();
10766 const auto byte2_raw =
get();
10772 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
10773 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
10783 const auto half =
static_cast<unsigned int>((byte2 << 8u) + byte1);
10784 const double val = [&half]
10786 const int exp = (half >> 10u) & 0x1Fu;
10787 const unsigned int mant = half & 0x3FFu;
10793 return std::ldexp(mant, -24);
10796 ? std::numeric_limits<double>::infinity()
10797 :
std::numeric_limits<double>::quiet_NaN();
10799 return std::ldexp(mant + 1024,
exp - 25);
10802 return sax->number_float((half & 0x8000u) != 0
10803 ?
static_cast<number_float_t
>(-
val)
10804 : static_cast<number_float_t>(
val),
"");
10810 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10816 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10821 return get_ubjson_high_precision_number();
10833 auto last_token = get_token_string();
10835 exception_message(input_format,
concat(
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token),
"char"),
nullptr));
10837 string_t s(1,
static_cast<typename string_t::value_type
>(current));
10838 return sax->string(s);
10844 return get_ubjson_string(s) && sax->string(s);
10848 return get_ubjson_array();
10851 return get_ubjson_object();
10856 auto last_token = get_token_string();
10857 return sax->parse_error(chars_read, last_token,
parse_error::create(112, chars_read, exception_message(input_format,
"invalid byte: 0x" + last_token,
"value"),
nullptr));
10863 bool get_ubjson_array()
10865 std::pair<std::size_t, char_int_type> size_and_type;
10874 if (input_format == input_format_t::bjdata && size_and_type.first != string_t::npos && size_and_type.first >= (1ull << (
sizeof(std::size_t) * 8 - 1)))
10876 std::map<char_int_type, string_t> bjdtype = {{
'U',
"uint8"}, {
'i',
"int8"}, {
'u',
"uint16"}, {
'I',
"int16"},
10877 {
'm',
"uint32"}, {
'l',
"int32"}, {
'M',
"uint64"}, {
'L',
"int64"}, {
'd',
"single"}, {
'D',
"double"}, {
'C',
"char"}
10880 string_t key =
"_ArrayType_";
10881 if (
JSON_HEDLEY_UNLIKELY(bjdtype.count(size_and_type.second) == 0 || !sax->key(key) || !sax->string(bjdtype[size_and_type.second]) ))
10886 if (size_and_type.second ==
'C')
10888 size_and_type.second =
'U';
10891 size_and_type.first &= ~(1ull << (
sizeof(std::size_t) * 8 - 1));
10892 key =
"_ArrayData_";
10898 for (std::size_t i = 0; i < size_and_type.first; ++i)
10906 return (sax->end_array() && sax->end_object());
10909 if (size_and_type.first != string_t::npos)
10916 if (size_and_type.second != 0)
10918 if (size_and_type.second !=
'N')
10920 for (std::size_t i = 0; i < size_and_type.first; ++i)
10931 for (std::size_t i = 0; i < size_and_type.first; ++i)
10947 while (current !=
']')
10957 return sax->end_array();
10963 bool get_ubjson_object()
10965 std::pair<std::size_t, char_int_type> size_and_type;
10971 if (input_format == input_format_t::bjdata && size_and_type.first != string_t::npos && size_and_type.first >= (1ull << (
sizeof(std::size_t) * 8 - 1)))
10977 if (size_and_type.first != string_t::npos)
10984 if (size_and_type.second != 0)
10986 for (std::size_t i = 0; i < size_and_type.first; ++i)
11001 for (std::size_t i = 0; i < size_and_type.first; ++i)
11022 while (current !=
'}')
11037 return sax->end_object();
11043 bool get_ubjson_high_precision_number()
11046 std::size_t
size{};
11047 auto res = get_ubjson_size_value(
size);
11054 std::vector<char> number_vector;
11055 for (std::size_t i = 0; i <
size; ++i)
11062 number_vector.push_back(
static_cast<char>(current));
11066 using ia_type =
decltype(detail::input_adapter(number_vector));
11067 auto number_lexer = detail::lexer<BasicJsonType, ia_type>(detail::input_adapter(number_vector),
false);
11068 const auto result_number = number_lexer.scan();
11069 const auto number_string = number_lexer.get_token_string();
11070 const auto result_remainder = number_lexer.scan();
11077 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11080 switch (result_number)
11082 case token_type::value_integer:
11083 return sax->number_integer(number_lexer.get_number_integer());
11084 case token_type::value_unsigned:
11085 return sax->number_unsigned(number_lexer.get_number_unsigned());
11086 case token_type::value_float:
11087 return sax->number_float(number_lexer.get_number_float(),
std::move(number_string));
11088 case token_type::uninitialized:
11089 case token_type::literal_true:
11090 case token_type::literal_false:
11091 case token_type::literal_null:
11092 case token_type::value_string:
11093 case token_type::begin_array:
11094 case token_type::begin_object:
11095 case token_type::end_array:
11096 case token_type::end_object:
11097 case token_type::name_separator:
11098 case token_type::value_separator:
11099 case token_type::parse_error:
11100 case token_type::end_of_input:
11101 case token_type::literal_or_value:
11104 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11121 char_int_type
get()
11124 return current = ia.get_character();
11130 char_int_type get_ignore_noop()
11136 while (current ==
'N');
11156 template<
typename NumberType,
bool InputIsLittleEndian = false>
11157 bool get_number(
const input_format_t
format, NumberType&
result)
11160 std::array<std::uint8_t,
sizeof(NumberType)> vec{};
11161 for (std::size_t i = 0; i <
sizeof(NumberType); ++i)
11170 if (is_little_endian != (InputIsLittleEndian ||
format == input_format_t::bjdata))
11172 vec[
sizeof(NumberType) - i - 1] =
static_cast<std::uint8_t
>(current);
11176 vec[i] =
static_cast<std::uint8_t
>(current);
11181 std::memcpy(&
result, vec.data(),
sizeof(NumberType));
11199 template<
typename NumberType>
11200 bool get_string(
const input_format_t
format,
11201 const NumberType
len,
11204 bool success =
true;
11205 for (NumberType i = 0; i <
len; i++)
11213 result.push_back(
static_cast<typename string_t::value_type
>(current));
11232 template<
typename NumberType>
11233 bool get_binary(
const input_format_t
format,
11234 const NumberType
len,
11237 bool success =
true;
11238 for (NumberType i = 0; i <
len; i++)
11246 result.push_back(
static_cast<std::uint8_t
>(current));
11257 bool unexpect_eof(const input_format_t
format, const
char* context)
const
11261 return sax->parse_error(chars_read,
"<end of file>",
11270 std::string get_token_string()
const
11272 std::array<char, 3> cr{{}};
11273 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current)));
11274 return std::string{cr.data()};
11283 std::string exception_message(
const input_format_t
format,
11284 const std::string& detail,
11285 const std::string& context)
const
11287 std::string error_msg =
"syntax error while parsing ";
11291 case input_format_t::cbor:
11292 error_msg +=
"CBOR";
11295 case input_format_t::msgpack:
11296 error_msg +=
"MessagePack";
11299 case input_format_t::ubjson:
11300 error_msg +=
"UBJSON";
11303 case input_format_t::bson:
11304 error_msg +=
"BSON";
11307 case input_format_t::bjdata:
11308 error_msg +=
"BJData";
11311 case input_format_t::json:
11316 return concat(error_msg,
' ', context,
": ", detail);
11321 InputAdapterType ia;
11324 char_int_type current = std::char_traits<char_type>::eof();
11327 std::size_t chars_read = 0;
11330 const bool is_little_endian = little_endianness();
11333 const input_format_t input_format = input_format_t::json;
11336 json_sax_t* sax =
nullptr;
11350#include <functional>
11380enum class parse_event_t : std::uint8_t
11396template<
typename BasicJsonType>
11397using parser_callback_t =
11398 std::function<
bool(
int , parse_event_t , BasicJsonType& )>;
11405template<
typename BasicJsonType,
typename InputAdapterType>
11408 using number_integer_t =
typename BasicJsonType::number_integer_t;
11409 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
11410 using number_float_t =
typename BasicJsonType::number_float_t;
11411 using string_t =
typename BasicJsonType::string_t;
11412 using lexer_t = lexer<BasicJsonType, InputAdapterType>;
11417 explicit parser(InputAdapterType&& adapter,
11418 const parser_callback_t<BasicJsonType> cb =
nullptr,
11419 const bool allow_exceptions_ =
true,
11420 const bool skip_comments =
false)
11422 , m_lexer(
std::
move(adapter), skip_comments)
11423 , allow_exceptions(allow_exceptions_)
11443 json_sax_dom_callback_parser<BasicJsonType> sdp(
result, callback, allow_exceptions);
11444 sax_parse_internal(&sdp);
11447 if (
strict && (get_token() != token_type::end_of_input))
11449 sdp.parse_error(m_lexer.get_position(),
11450 m_lexer.get_token_string(),
11452 exception_message(token_type::end_of_input,
"value"),
nullptr));
11456 if (sdp.is_errored())
11464 if (
result.is_discarded())
11471 json_sax_dom_parser<BasicJsonType> sdp(
result, allow_exceptions);
11472 sax_parse_internal(&sdp);
11475 if (
strict && (get_token() != token_type::end_of_input))
11477 sdp.parse_error(m_lexer.get_position(),
11478 m_lexer.get_token_string(),
11479 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
11483 if (sdp.is_errored())
11490 result.assert_invariant();
11499 bool accept(
const bool strict =
true)
11501 json_sax_acceptor<BasicJsonType> sax_acceptor;
11502 return sax_parse(&sax_acceptor,
strict);
11505 template<
typename SAX>
11509 (
void)detail::is_sax_static_asserts<SAX, BasicJsonType> {};
11510 const bool result = sax_parse_internal(sax);
11513 if (
result &&
strict && (get_token() != token_type::end_of_input))
11515 return sax->parse_error(m_lexer.get_position(),
11516 m_lexer.get_token_string(),
11517 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
11524 template<
typename SAX>
11526 bool sax_parse_internal(SAX* sax)
11530 std::vector<bool> states;
11532 bool skip_to_state_evaluation =
false;
11536 if (!skip_to_state_evaluation)
11539 switch (last_token)
11541 case token_type::begin_object:
11549 if (get_token() == token_type::end_object)
11561 return sax->parse_error(m_lexer.get_position(),
11562 m_lexer.get_token_string(),
11563 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
11573 return sax->parse_error(m_lexer.get_position(),
11574 m_lexer.get_token_string(),
11575 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
11579 states.push_back(
false);
11586 case token_type::begin_array:
11594 if (get_token() == token_type::end_array)
11604 states.push_back(
true);
11610 case token_type::value_float:
11612 const auto res = m_lexer.get_number_float();
11616 return sax->parse_error(m_lexer.get_position(),
11617 m_lexer.get_token_string(),
11629 case token_type::literal_false:
11638 case token_type::literal_null:
11647 case token_type::literal_true:
11656 case token_type::value_integer:
11665 case token_type::value_string:
11674 case token_type::value_unsigned:
11683 case token_type::parse_error:
11686 return sax->parse_error(m_lexer.get_position(),
11687 m_lexer.get_token_string(),
11688 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized,
"value"),
nullptr));
11691 case token_type::uninitialized:
11692 case token_type::end_array:
11693 case token_type::end_object:
11694 case token_type::name_separator:
11695 case token_type::value_separator:
11696 case token_type::end_of_input:
11697 case token_type::literal_or_value:
11700 return sax->parse_error(m_lexer.get_position(),
11701 m_lexer.get_token_string(),
11702 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
11708 skip_to_state_evaluation =
false;
11712 if (states.empty())
11721 if (get_token() == token_type::value_separator)
11742 skip_to_state_evaluation =
true;
11746 return sax->parse_error(m_lexer.get_position(),
11747 m_lexer.get_token_string(),
11748 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array,
"array"),
nullptr));
11754 if (get_token() == token_type::value_separator)
11759 return sax->parse_error(m_lexer.get_position(),
11760 m_lexer.get_token_string(),
11761 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
11772 return sax->parse_error(m_lexer.get_position(),
11773 m_lexer.get_token_string(),
11774 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
11796 skip_to_state_evaluation =
true;
11800 return sax->parse_error(m_lexer.get_position(),
11801 m_lexer.get_token_string(),
11802 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object,
"object"),
nullptr));
11807 token_type get_token()
11809 return last_token = m_lexer.scan();
11812 std::string exception_message(
const token_type expected,
const std::string& context)
11814 std::string error_msg =
"syntax error ";
11816 if (!context.empty())
11818 error_msg +=
concat(
"while parsing ", context,
' ');
11823 if (last_token == token_type::parse_error)
11825 error_msg +=
concat(m_lexer.get_error_message(),
"; last read: '",
11826 m_lexer.get_token_string(),
'\'');
11833 if (expected != token_type::uninitialized)
11843 const parser_callback_t<BasicJsonType> callback =
nullptr;
11845 token_type last_token = token_type::uninitialized;
11849 const bool allow_exceptions =
true;
11880class primitive_iterator_t
11883 using difference_type = std::ptrdiff_t;
11884 static constexpr difference_type begin_value = 0;
11885 static constexpr difference_type end_value = begin_value + 1;
11889 difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
11892 constexpr difference_type get_value() const noexcept
11898 void set_begin() noexcept
11900 m_it = begin_value;
11904 void set_end() noexcept
11910 constexpr bool is_begin() const noexcept
11912 return m_it == begin_value;
11916 constexpr bool is_end() const noexcept
11918 return m_it == end_value;
11921 friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs)
noexcept
11923 return lhs.m_it == rhs.m_it;
11926 friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs)
noexcept
11928 return lhs.m_it < rhs.m_it;
11931 primitive_iterator_t
operator+(difference_type n)
noexcept
11938 friend constexpr difference_type
operator-(primitive_iterator_t lhs, primitive_iterator_t rhs)
noexcept
11940 return lhs.m_it - rhs.m_it;
11943 primitive_iterator_t& operator++() noexcept
11949 primitive_iterator_t operator++(
int)&
noexcept
11956 primitive_iterator_t& operator--() noexcept
11962 primitive_iterator_t operator--(
int)&
noexcept
11969 primitive_iterator_t&
operator+=(difference_type n)
noexcept
11975 primitive_iterator_t& operator-=(difference_type n)
noexcept
12011#include <type_traits>
12033template<
typename IteratorType>
class iteration_proxy;
12034template<
typename IteratorType>
class iteration_proxy_value;
12052template<
typename BasicJsonType>
12059 friend BasicJsonType;
12060 friend iteration_proxy<iter_impl>;
12061 friend iteration_proxy_value<iter_impl>;
12063 using object_t =
typename BasicJsonType::object_t;
12064 using array_t =
typename BasicJsonType::array_t;
12067 "iter_impl only accepts (const) basic_json");
12083 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
12084 typename BasicJsonType::const_pointer,
12085 typename BasicJsonType::pointer>
::type;
12088 typename std::conditional<std::is_const<BasicJsonType>::value,
12089 typename BasicJsonType::const_reference,
12090 typename BasicJsonType::reference>
::type;
12107 switch (m_object->m_type)
12154 : m_object(other.m_object),
m_it(other.m_it)
12165 if (&other !=
this)
12167 m_object = other.m_object;
12179 : m_object(other.m_object),
m_it(other.m_it)
12190 m_object = other.m_object;
12200 void set_begin() noexcept
12204 switch (m_object->m_type)
12248 switch (m_object->m_type)
12287 switch (m_object->m_type)
12331 switch (m_object->m_type)
12384 switch (m_object->m_type)
12435 switch (m_object->m_type)
12471 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
12482 switch (m_object->m_type)
12507 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
12527 switch (m_object->m_type)
12554 return !other.operator < (*this);
12583 switch (m_object->m_type)
12662 switch (m_object->m_type)
12691 switch (m_object->m_type)
12725 const typename object_t::key_type&
key()
const
12790template<
typename Base>
12864 auto it = --this->base();
12871 auto it = --this->base();
12872 return it.operator * ();
12883#include <algorithm>
12909template<
typename RefStringType>
12919 template<
typename T>
12920 struct string_t_helper
12928 using type = StringType;
12933 using string_t =
typename string_t_helper<RefStringType>::type;
12938 : reference_tokens(split(s))
12945 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
12949 return detail::concat(a,
'/', detail::escape(b));
12964 reference_tokens.insert(reference_tokens.end(),
12965 ptr.reference_tokens.begin(),
12966 ptr.reference_tokens.end());
12982 return *
this /= std::to_string(array_idx);
13030 reference_tokens.pop_back();
13042 return reference_tokens.back();
13049 reference_tokens.push_back(token);
13056 reference_tokens.push_back(
std::move(token));
13063 return reference_tokens.empty();
13077 template<
typename BasicJsonType>
13078 static typename BasicJsonType::size_type array_index(
const string_t& s)
13080 using size_type =
typename BasicJsonType::size_type;
13094 const char* p = s.c_str();
13095 char* p_end =
nullptr;
13097 unsigned long long res = std::strtoull(p, &p_end, 10);
13107 if (
res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
13112 return static_cast<size_type
>(
res);
13124 result.reference_tokens = {reference_tokens[0]};
13137 template<
typename BasicJsonType>
13138 BasicJsonType& get_and_create(BasicJsonType& j)
const
13144 for (
const auto& reference_token : reference_tokens)
13150 if (reference_token ==
"0")
13173 result = &
result->operator[](array_index<BasicJsonType>(reference_token));
13217 template<
typename BasicJsonType>
13218 BasicJsonType& get_unchecked(BasicJsonType* ptr)
const
13220 for (
const auto& reference_token : reference_tokens)
13223 if (ptr->is_null())
13227 std::all_of(reference_token.begin(), reference_token.end(),
13228 [](
const unsigned char x)
13230 return std::isdigit(x);
13234 *ptr = (nums || reference_token ==
"-")
13239 switch (ptr->type())
13244 ptr = &ptr->operator[](reference_token);
13250 if (reference_token ==
"-")
13253 ptr = &ptr->operator[](ptr->m_value.array->size());
13258 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
13285 template<
typename BasicJsonType>
13286 BasicJsonType& get_checked(BasicJsonType* ptr)
const
13288 for (
const auto& reference_token : reference_tokens)
13290 switch (ptr->type())
13295 ptr = &ptr->at(reference_token);
13305 "array index '-' (", std::to_string(ptr->m_value.array->size()),
13306 ") is out of range"), ptr));
13310 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
13343 template<
typename BasicJsonType>
13344 const BasicJsonType& get_unchecked(
const BasicJsonType* ptr)
const
13346 for (
const auto& reference_token : reference_tokens)
13348 switch (ptr->type())
13353 ptr = &ptr->operator[](reference_token);
13366 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
13392 template<
typename BasicJsonType>
13393 const BasicJsonType& get_checked(
const BasicJsonType* ptr)
const
13395 for (
const auto& reference_token : reference_tokens)
13397 switch (ptr->type())
13402 ptr = &ptr->at(reference_token);
13412 "array index '-' (", std::to_string(ptr->m_value.array->size()),
13413 ") is out of range"), ptr));
13417 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
13441 template<
typename BasicJsonType>
13442 bool contains(
const BasicJsonType* ptr)
const
13444 for (
const auto& reference_token : reference_tokens)
13446 switch (ptr->type())
13450 if (!ptr->contains(reference_token))
13456 ptr = &ptr->operator[](reference_token);
13467 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
13479 for (std::size_t i = 1; i < reference_token.size(); i++)
13489 const auto idx = array_index<BasicJsonType>(reference_token);
13490 if (idx >= ptr->size())
13496 ptr = &ptr->operator[](idx);
13530 static std::vector<string_t> split(
const string_t& reference_string)
13532 std::vector<string_t>
result;
13535 if (reference_string.empty())
13551 std::size_t slash = reference_string.find_first_of(
'/', 1),
13558 start = (slash == string_t::npos) ? 0 : slash + 1,
13564 auto reference_token = reference_string.substr(
start, slash -
start);
13567 for (std::size_t pos = reference_token.find_first_of(
'~');
13568 pos != string_t::npos;
13569 pos = reference_token.find_first_of(
'~', pos + 1))
13575 (reference_token[pos + 1] !=
'0' &&
13576 reference_token[pos + 1] !=
'1')))
13583 detail::unescape(reference_token);
13584 result.push_back(reference_token);
13598 template<
typename BasicJsonType>
13599 static void flatten(
const string_t& reference_string,
13600 const BasicJsonType&
value,
13603 switch (
value.type())
13607 if (
value.m_value.array->empty())
13610 result[reference_string] =
nullptr;
13615 for (std::size_t i = 0; i <
value.m_value.array->size(); ++i)
13617 flatten(
detail::concat(reference_string,
'/', std::to_string(i)),
13626 if (
value.m_value.object->empty())
13629 result[reference_string] =
nullptr;
13634 for (
const auto& element : *
value.m_value.
object)
13669 template<
typename BasicJsonType>
13670 static BasicJsonType
13671 unflatten(
const BasicJsonType&
value)
13681 for (
const auto& element : *
value.m_value.
object)
13699 json_pointer<string_t> convert() const&
13701 json_pointer<string_t>
result;
13702 result.reference_tokens = reference_tokens;
13706 json_pointer<string_t> convert()&&
13708 json_pointer<string_t>
result;
13724 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
13726 friend bool operator==(json_pointer<RefStringTypeLhs>
const& lhs,
13727 json_pointer<RefStringTypeRhs>
const& rhs)
noexcept;
13740 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
13742 friend bool operator!=(json_pointer<RefStringTypeLhs>
const& lhs,
13743 json_pointer<RefStringTypeRhs>
const& rhs)
noexcept;
13746 std::vector<string_t> reference_tokens;
13750template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
13754 return lhs.reference_tokens == rhs.reference_tokens;
13757template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
13761 return !(lhs == rhs);
13768#include <initializer_list>
13778template<
typename BasicJsonType>
13789 : value_ref(&
value)
13793 : owned_value(init)
13800 : owned_value(
std::forward<Args>(args)...)
13812 if (value_ref ==
nullptr)
13821 return value_ref ? *value_ref : owned_value;
13849#include <algorithm>
13867#include <algorithm>
13887template<
typename CharType>
struct output_adapter_protocol
13889 virtual void write_character(CharType c) = 0;
13890 virtual void write_characters(
const CharType* s, std::size_t
length) = 0;
13891 virtual ~output_adapter_protocol() =
default;
13893 output_adapter_protocol() =
default;
13894 output_adapter_protocol(
const output_adapter_protocol&) =
default;
13895 output_adapter_protocol(output_adapter_protocol&&) noexcept = default;
13896 output_adapter_protocol& operator=(const output_adapter_protocol&) = default;
13897 output_adapter_protocol& operator=(output_adapter_protocol&&) noexcept = default;
13901template<typename CharType>
13902using output_adapter_t =
std::shared_ptr<output_adapter_protocol<CharType>>;
13905template<typename CharType, typename AllocatorType =
std::allocator<CharType>>
13906class output_vector_adapter : public output_adapter_protocol<CharType>
13909 explicit output_vector_adapter(std::vector<CharType, AllocatorType>& vec) noexcept
13913 void write_character(CharType c)
override
13919 void write_characters(const CharType* s,
std::
size_t length)
override
13925 std::vector<CharType, AllocatorType>&
v;
13930template<
typename CharType>
13931class output_stream_adapter :
public output_adapter_protocol<CharType>
13934 explicit output_stream_adapter(std::basic_ostream<CharType>& s) noexcept
13938 void write_character(CharType c)
override
13944 void write_characters(const CharType* s,
std::
size_t length)
override
13946 stream.write(s,
static_cast<std::streamsize
>(
length));
13950 std::basic_ostream<CharType>&
stream;
13955template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
13956class output_string_adapter :
public output_adapter_protocol<CharType>
13959 explicit output_string_adapter(StringType& s) noexcept
13963 void write_character(CharType c)
override
13969 void write_characters(const CharType* s,
std::
size_t length)
override
13978template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
13979class output_adapter
13982 template<
typename AllocatorType = std::allocator<CharType>>
13983 output_adapter(std::vector<CharType, AllocatorType>& vec)
13984 : oa(
std::make_shared<output_vector_adapter<CharType, AllocatorType>>(vec)) {}
13987 output_adapter(std::basic_ostream<CharType>& s)
13988 : oa(
std::make_shared<output_stream_adapter<CharType>>(s)) {}
13991 output_adapter(StringType& s)
13992 : oa(
std::make_shared<output_string_adapter<CharType, StringType>>(s)) {}
13994 operator output_adapter_t<CharType>()
14000 output_adapter_t<CharType> oa =
nullptr;
14019template<
typename BasicJsonType,
typename CharType>
14022 using string_t =
typename BasicJsonType::string_t;
14023 using binary_t =
typename BasicJsonType::binary_t;
14024 using number_float_t =
typename BasicJsonType::number_float_t;
14032 explicit binary_writer(output_adapter_t<CharType> adapter) : oa(
std::
move(adapter))
14041 void write_bson(
const BasicJsonType& j)
14045 case value_t::object:
14047 write_bson_object(*j.m_value.object);
14051 case value_t::null:
14052 case value_t::array:
14053 case value_t::string:
14054 case value_t::boolean:
14055 case value_t::number_integer:
14056 case value_t::number_unsigned:
14057 case value_t::number_float:
14058 case value_t::binary:
14059 case value_t::discarded:
14062 JSON_THROW(type_error::create(317,
concat(
"to serialize to BSON, top-level type must be object, but is ", j.type_name()), &j));
14070 void write_cbor(
const BasicJsonType& j)
14074 case value_t::null:
14076 oa->write_character(to_char_type(0xF6));
14080 case value_t::boolean:
14082 oa->write_character(j.m_value.boolean
14083 ? to_char_type(0xF5)
14084 : to_char_type(0xF4));
14088 case value_t::number_integer:
14090 if (j.m_value.number_integer >= 0)
14095 if (j.m_value.number_integer <= 0x17)
14097 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14099 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
14101 oa->write_character(to_char_type(0x18));
14102 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14104 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
14106 oa->write_character(to_char_type(0x19));
14107 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
14109 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
14111 oa->write_character(to_char_type(0x1A));
14112 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
14116 oa->write_character(to_char_type(0x1B));
14117 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
14124 const auto positive_number = -1 - j.m_value.number_integer;
14125 if (j.m_value.number_integer >= -24)
14127 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
14129 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
14131 oa->write_character(to_char_type(0x38));
14132 write_number(
static_cast<std::uint8_t
>(positive_number));
14134 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
14136 oa->write_character(to_char_type(0x39));
14137 write_number(
static_cast<std::uint16_t
>(positive_number));
14139 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
14141 oa->write_character(to_char_type(0x3A));
14142 write_number(
static_cast<std::uint32_t
>(positive_number));
14146 oa->write_character(to_char_type(0x3B));
14147 write_number(
static_cast<std::uint64_t
>(positive_number));
14153 case value_t::number_unsigned:
14155 if (j.m_value.number_unsigned <= 0x17)
14157 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
14159 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
14161 oa->write_character(to_char_type(0x18));
14162 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
14164 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
14166 oa->write_character(to_char_type(0x19));
14167 write_number(
static_cast<std::uint16_t
>(j.m_value.number_unsigned));
14169 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
14171 oa->write_character(to_char_type(0x1A));
14172 write_number(
static_cast<std::uint32_t
>(j.m_value.number_unsigned));
14176 oa->write_character(to_char_type(0x1B));
14177 write_number(
static_cast<std::uint64_t
>(j.m_value.number_unsigned));
14182 case value_t::number_float:
14184 if (std::isnan(j.m_value.number_float))
14187 oa->write_character(to_char_type(0xF9));
14188 oa->write_character(to_char_type(0x7E));
14189 oa->write_character(to_char_type(0x00));
14191 else if (std::isinf(j.m_value.number_float))
14194 oa->write_character(to_char_type(0xf9));
14195 oa->write_character(j.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
14196 oa->write_character(to_char_type(0x00));
14200 write_compact_float(j.m_value.number_float, detail::input_format_t::cbor);
14205 case value_t::string:
14208 const auto N = j.m_value.string->size();
14211 write_number(
static_cast<std::uint8_t
>(0x60 + N));
14213 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14215 oa->write_character(to_char_type(0x78));
14216 write_number(
static_cast<std::uint8_t
>(N));
14218 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14220 oa->write_character(to_char_type(0x79));
14221 write_number(
static_cast<std::uint16_t
>(N));
14223 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14225 oa->write_character(to_char_type(0x7A));
14226 write_number(
static_cast<std::uint32_t
>(N));
14229 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
14231 oa->write_character(to_char_type(0x7B));
14232 write_number(
static_cast<std::uint64_t
>(N));
14237 oa->write_characters(
14238 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
14239 j.m_value.string->size());
14243 case value_t::array:
14246 const auto N = j.m_value.array->size();
14249 write_number(
static_cast<std::uint8_t
>(0x80 + N));
14251 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14253 oa->write_character(to_char_type(0x98));
14254 write_number(
static_cast<std::uint8_t
>(N));
14256 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14258 oa->write_character(to_char_type(0x99));
14259 write_number(
static_cast<std::uint16_t
>(N));
14261 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14263 oa->write_character(to_char_type(0x9A));
14264 write_number(
static_cast<std::uint32_t
>(N));
14267 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
14269 oa->write_character(to_char_type(0x9B));
14270 write_number(
static_cast<std::uint64_t
>(N));
14275 for (
const auto& el : *j.m_value.
array)
14282 case value_t::binary:
14284 if (j.m_value.binary->has_subtype())
14286 if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
14288 write_number(
static_cast<std::uint8_t
>(0xd8));
14289 write_number(
static_cast<std::uint8_t
>(j.m_value.binary->subtype()));
14291 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
14293 write_number(
static_cast<std::uint8_t
>(0xd9));
14294 write_number(
static_cast<std::uint16_t
>(j.m_value.binary->subtype()));
14296 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
14298 write_number(
static_cast<std::uint8_t
>(0xda));
14299 write_number(
static_cast<std::uint32_t
>(j.m_value.binary->subtype()));
14301 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
14303 write_number(
static_cast<std::uint8_t
>(0xdb));
14304 write_number(
static_cast<std::uint64_t
>(j.m_value.binary->subtype()));
14309 const auto N = j.m_value.binary->size();
14312 write_number(
static_cast<std::uint8_t
>(0x40 + N));
14314 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14316 oa->write_character(to_char_type(0x58));
14317 write_number(
static_cast<std::uint8_t
>(N));
14319 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14321 oa->write_character(to_char_type(0x59));
14322 write_number(
static_cast<std::uint16_t
>(N));
14324 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14326 oa->write_character(to_char_type(0x5A));
14327 write_number(
static_cast<std::uint32_t
>(N));
14330 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
14332 oa->write_character(to_char_type(0x5B));
14333 write_number(
static_cast<std::uint64_t
>(N));
14338 oa->write_characters(
14339 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
14345 case value_t::object:
14348 const auto N = j.m_value.object->size();
14351 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
14353 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14355 oa->write_character(to_char_type(0xB8));
14356 write_number(
static_cast<std::uint8_t
>(N));
14358 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14360 oa->write_character(to_char_type(0xB9));
14361 write_number(
static_cast<std::uint16_t
>(N));
14363 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14365 oa->write_character(to_char_type(0xBA));
14366 write_number(
static_cast<std::uint32_t
>(N));
14369 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
14371 oa->write_character(to_char_type(0xBB));
14372 write_number(
static_cast<std::uint64_t
>(N));
14377 for (
const auto& el : *j.m_value.
object)
14379 write_cbor(el.first);
14380 write_cbor(el.second);
14385 case value_t::discarded:
14394 void write_msgpack(
const BasicJsonType& j)
14398 case value_t::null:
14400 oa->write_character(to_char_type(0xC0));
14404 case value_t::boolean:
14406 oa->write_character(j.m_value.boolean
14407 ? to_char_type(0xC3)
14408 : to_char_type(0xC2));
14412 case value_t::number_integer:
14414 if (j.m_value.number_integer >= 0)
14419 if (j.m_value.number_unsigned < 128)
14422 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14424 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
14427 oa->write_character(to_char_type(0xCC));
14428 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14430 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
14433 oa->write_character(to_char_type(0xCD));
14434 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
14436 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
14439 oa->write_character(to_char_type(0xCE));
14440 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
14442 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
14445 oa->write_character(to_char_type(0xCF));
14446 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
14451 if (j.m_value.number_integer >= -32)
14454 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
14456 else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
14457 j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
14460 oa->write_character(to_char_type(0xD0));
14461 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
14463 else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
14464 j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
14467 oa->write_character(to_char_type(0xD1));
14468 write_number(
static_cast<std::int16_t
>(j.m_value.number_integer));
14470 else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
14471 j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
14474 oa->write_character(to_char_type(0xD2));
14475 write_number(
static_cast<std::int32_t
>(j.m_value.number_integer));
14477 else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
14478 j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
14481 oa->write_character(to_char_type(0xD3));
14482 write_number(
static_cast<std::int64_t
>(j.m_value.number_integer));
14488 case value_t::number_unsigned:
14490 if (j.m_value.number_unsigned < 128)
14493 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14495 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
14498 oa->write_character(to_char_type(0xCC));
14499 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14501 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
14504 oa->write_character(to_char_type(0xCD));
14505 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
14507 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
14510 oa->write_character(to_char_type(0xCE));
14511 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
14513 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
14516 oa->write_character(to_char_type(0xCF));
14517 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
14522 case value_t::number_float:
14524 write_compact_float(j.m_value.number_float, detail::input_format_t::msgpack);
14528 case value_t::string:
14531 const auto N = j.m_value.string->size();
14535 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
14537 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14540 oa->write_character(to_char_type(0xD9));
14541 write_number(
static_cast<std::uint8_t
>(N));
14543 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14546 oa->write_character(to_char_type(0xDA));
14547 write_number(
static_cast<std::uint16_t
>(N));
14549 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14552 oa->write_character(to_char_type(0xDB));
14553 write_number(
static_cast<std::uint32_t
>(N));
14557 oa->write_characters(
14558 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
14559 j.m_value.string->size());
14563 case value_t::array:
14566 const auto N = j.m_value.array->size();
14570 write_number(
static_cast<std::uint8_t
>(0x90 | N));
14572 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14575 oa->write_character(to_char_type(0xDC));
14576 write_number(
static_cast<std::uint16_t
>(N));
14578 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14581 oa->write_character(to_char_type(0xDD));
14582 write_number(
static_cast<std::uint32_t
>(N));
14586 for (
const auto& el : *j.m_value.
array)
14593 case value_t::binary:
14597 const bool use_ext = j.m_value.binary->has_subtype();
14600 const auto N = j.m_value.binary->size();
14601 if (N <= (std::numeric_limits<std::uint8_t>::max)())
14603 std::uint8_t output_type{};
14610 output_type = 0xD4;
14613 output_type = 0xD5;
14616 output_type = 0xD6;
14619 output_type = 0xD7;
14622 output_type = 0xD8;
14625 output_type = 0xC7;
14633 output_type = 0xC4;
14637 oa->write_character(to_char_type(output_type));
14640 write_number(
static_cast<std::uint8_t
>(N));
14643 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14645 std::uint8_t output_type = use_ext
14649 oa->write_character(to_char_type(output_type));
14650 write_number(
static_cast<std::uint16_t
>(N));
14652 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14654 std::uint8_t output_type = use_ext
14658 oa->write_character(to_char_type(output_type));
14659 write_number(
static_cast<std::uint32_t
>(N));
14665 write_number(
static_cast<std::int8_t
>(j.m_value.binary->subtype()));
14669 oa->write_characters(
14670 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
14676 case value_t::object:
14679 const auto N = j.m_value.object->size();
14683 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
14685 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14688 oa->write_character(to_char_type(0xDE));
14689 write_number(
static_cast<std::uint16_t
>(N));
14691 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14694 oa->write_character(to_char_type(0xDF));
14695 write_number(
static_cast<std::uint32_t
>(N));
14699 for (
const auto& el : *j.m_value.
object)
14701 write_msgpack(el.first);
14702 write_msgpack(el.second);
14707 case value_t::discarded:
14720 void write_ubjson(
const BasicJsonType& j,
const bool use_count,
14721 const bool use_type,
const bool add_prefix =
true,
14722 const bool use_bjdata =
false)
14726 case value_t::null:
14730 oa->write_character(to_char_type(
'Z'));
14735 case value_t::boolean:
14739 oa->write_character(j.m_value.boolean
14740 ? to_char_type(
'T')
14741 : to_char_type(
'F'));
14746 case value_t::number_integer:
14748 write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix, use_bjdata);
14752 case value_t::number_unsigned:
14754 write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix, use_bjdata);
14758 case value_t::number_float:
14760 write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix, use_bjdata);
14764 case value_t::string:
14768 oa->write_character(to_char_type(
'S'));
14770 write_number_with_ubjson_prefix(j.m_value.string->size(),
true, use_bjdata);
14771 oa->write_characters(
14772 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
14773 j.m_value.string->size());
14777 case value_t::array:
14781 oa->write_character(to_char_type(
'['));
14784 bool prefix_required =
true;
14785 if (use_type && !j.m_value.array->empty())
14788 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
14789 const bool same_prefix =
std::all_of(j.begin() + 1, j.end(),
14790 [
this, first_prefix, use_bjdata](
const BasicJsonType &
v)
14792 return ubjson_prefix(v, use_bjdata) == first_prefix;
14795 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
14797 if (same_prefix && !(use_bjdata &&
std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
14799 prefix_required =
false;
14800 oa->write_character(to_char_type(
'$'));
14801 oa->write_character(first_prefix);
14807 oa->write_character(to_char_type(
'#'));
14808 write_number_with_ubjson_prefix(j.m_value.array->size(),
true, use_bjdata);
14811 for (
const auto& el : *j.m_value.
array)
14813 write_ubjson(el, use_count, use_type, prefix_required, use_bjdata);
14818 oa->write_character(to_char_type(
']'));
14824 case value_t::binary:
14828 oa->write_character(to_char_type(
'['));
14831 if (use_type && !j.m_value.binary->empty())
14834 oa->write_character(to_char_type(
'$'));
14835 oa->write_character(
'U');
14840 oa->write_character(to_char_type(
'#'));
14841 write_number_with_ubjson_prefix(j.m_value.binary->size(),
true, use_bjdata);
14846 oa->write_characters(
14847 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
14848 j.m_value.binary->size());
14852 for (
size_t i = 0; i < j.m_value.binary->size(); ++i)
14854 oa->write_character(to_char_type(
'U'));
14855 oa->write_character(j.m_value.binary->data()[i]);
14861 oa->write_character(to_char_type(
']'));
14867 case value_t::object:
14869 if (use_bjdata && j.m_value.object->size() == 3 && j.m_value.object->find(
"_ArrayType_") != j.m_value.object->end() && j.m_value.object->find(
"_ArraySize_") != j.m_value.object->end() && j.m_value.object->find(
"_ArrayData_") != j.m_value.object->end())
14871 if (!write_bjdata_ndarray(*j.m_value.object, use_count, use_type))
14879 oa->write_character(to_char_type(
'{'));
14882 bool prefix_required =
true;
14883 if (use_type && !j.m_value.object->empty())
14886 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
14887 const bool same_prefix =
std::all_of(j.begin(), j.end(),
14888 [
this, first_prefix, use_bjdata](
const BasicJsonType &
v)
14890 return ubjson_prefix(v, use_bjdata) == first_prefix;
14893 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
14895 if (same_prefix && !(use_bjdata &&
std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
14897 prefix_required =
false;
14898 oa->write_character(to_char_type(
'$'));
14899 oa->write_character(first_prefix);
14905 oa->write_character(to_char_type(
'#'));
14906 write_number_with_ubjson_prefix(j.m_value.object->size(),
true, use_bjdata);
14909 for (
const auto& el : *j.m_value.
object)
14911 write_number_with_ubjson_prefix(el.first.size(),
true, use_bjdata);
14912 oa->write_characters(
14913 reinterpret_cast<const CharType*
>(el.first.c_str()),
14915 write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata);
14920 oa->write_character(to_char_type(
'}'));
14926 case value_t::discarded:
14941 static std::size_t calc_bson_entry_header_size(
const string_t&
name,
const BasicJsonType& j)
14943 const auto it =
name.find(
static_cast<typename string_t::value_type
>(0));
14946 JSON_THROW(out_of_range::create(409,
concat(
"BSON key cannot contain code point U+0000 (at byte ", std::to_string(it),
")"), &j));
14947 static_cast<void>(j);
14950 return 1ul +
name.size() + 1u;
14956 void write_bson_entry_header(
const string_t&
name,
14957 const std::uint8_t element_type)
14959 oa->write_character(to_char_type(element_type));
14960 oa->write_characters(
14961 reinterpret_cast<const CharType*
>(
name.c_str()),
14968 void write_bson_boolean(
const string_t&
name,
14971 write_bson_entry_header(
name, 0x08);
14972 oa->write_character(
value ? to_char_type(0x01) : to_char_type(0x00));
14978 void write_bson_double(
const string_t&
name,
14979 const double value)
14981 write_bson_entry_header(
name, 0x01);
14982 write_number<double>(
value,
true);
14988 static std::size_t calc_bson_string_size(
const string_t&
value)
14990 return sizeof(std::int32_t) +
value.size() + 1ul;
14996 void write_bson_string(
const string_t&
name,
14997 const string_t&
value)
14999 write_bson_entry_header(
name, 0x02);
15001 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size() + 1ul),
true);
15002 oa->write_characters(
15003 reinterpret_cast<const CharType*
>(
value.c_str()),
15010 void write_bson_null(
const string_t&
name)
15012 write_bson_entry_header(
name, 0x0A);
15018 static std::size_t calc_bson_integer_size(
const std::int64_t
value)
15020 return (std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)()
15021 ?
sizeof(std::int32_t)
15022 :
sizeof(std::int64_t);
15028 void write_bson_integer(
const string_t&
name,
15029 const std::int64_t
value)
15031 if ((std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)())
15033 write_bson_entry_header(
name, 0x10);
15034 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value),
true);
15038 write_bson_entry_header(
name, 0x12);
15039 write_number<std::int64_t>(
static_cast<std::int64_t
>(
value),
true);
15046 static constexpr std::size_t calc_bson_unsigned_size(
const std::uint64_t
value)
noexcept
15048 return (
value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
15049 ?
sizeof(std::int32_t)
15056 void write_bson_unsigned(
const string_t&
name,
15057 const BasicJsonType& j)
15059 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
15061 write_bson_entry_header(
name, 0x10 );
15062 write_number<std::int32_t>(
static_cast<std::int32_t
>(j.m_value.number_unsigned),
true);
15064 else if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
15066 write_bson_entry_header(
name, 0x12 );
15067 write_number<std::int64_t>(
static_cast<std::int64_t
>(j.m_value.number_unsigned),
true);
15071 JSON_THROW(out_of_range::create(407,
concat(
"integer number ", std::to_string(j.m_value.number_unsigned),
" cannot be represented by BSON as it does not fit int64"), &j));
15078 void write_bson_object_entry(
const string_t&
name,
15079 const typename BasicJsonType::object_t&
value)
15081 write_bson_entry_header(
name, 0x03);
15082 write_bson_object(
value);
15088 static std::size_t calc_bson_array_size(
const typename BasicJsonType::array_t&
value)
15090 std::size_t array_index = 0ul;
15092 const std::size_t embedded_document_size = std::accumulate(std::begin(
value), std::end(
value),
static_cast<std::size_t
>(0), [&array_index](std::size_t
result,
const typename BasicJsonType::array_t::value_type & el)
15094 return result + calc_bson_element_size(std::to_string(array_index++), el);
15097 return sizeof(std::int32_t) + embedded_document_size + 1ul;
15103 static std::size_t calc_bson_binary_size(
const typename BasicJsonType::binary_t&
value)
15105 return sizeof(std::int32_t) +
value.size() + 1ul;
15111 void write_bson_array(
const string_t&
name,
15112 const typename BasicJsonType::array_t&
value)
15114 write_bson_entry_header(
name, 0x04);
15115 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_array_size(
value)),
true);
15117 std::size_t array_index = 0ul;
15119 for (
const auto& el :
value)
15121 write_bson_element(std::to_string(array_index++), el);
15124 oa->write_character(to_char_type(0x00));
15130 void write_bson_binary(
const string_t&
name,
15131 const binary_t&
value)
15133 write_bson_entry_header(
name, 0x05);
15135 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size()),
true);
15136 write_number(
value.has_subtype() ?
static_cast<std::uint8_t
>(
value.subtype()) : static_cast<
std::
uint8_t>(0x00));
15138 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
15145 static std::size_t calc_bson_element_size(
const string_t&
name,
15146 const BasicJsonType& j)
15148 const auto header_size = calc_bson_entry_header_size(
name, j);
15151 case value_t::object:
15152 return header_size + calc_bson_object_size(*j.m_value.object);
15154 case value_t::array:
15155 return header_size + calc_bson_array_size(*j.m_value.array);
15157 case value_t::binary:
15158 return header_size + calc_bson_binary_size(*j.m_value.binary);
15160 case value_t::boolean:
15161 return header_size + 1ul;
15163 case value_t::number_float:
15164 return header_size + 8ul;
15166 case value_t::number_integer:
15167 return header_size + calc_bson_integer_size(j.m_value.number_integer);
15169 case value_t::number_unsigned:
15170 return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned);
15172 case value_t::string:
15173 return header_size + calc_bson_string_size(*j.m_value.string);
15175 case value_t::null:
15176 return header_size + 0ul;
15179 case value_t::discarded:
15193 void write_bson_element(
const string_t&
name,
15194 const BasicJsonType& j)
15198 case value_t::object:
15199 return write_bson_object_entry(
name, *j.m_value.object);
15201 case value_t::array:
15202 return write_bson_array(
name, *j.m_value.array);
15204 case value_t::binary:
15205 return write_bson_binary(
name, *j.m_value.binary);
15207 case value_t::boolean:
15208 return write_bson_boolean(
name, j.m_value.boolean);
15210 case value_t::number_float:
15211 return write_bson_double(
name, j.m_value.number_float);
15213 case value_t::number_integer:
15214 return write_bson_integer(
name, j.m_value.number_integer);
15216 case value_t::number_unsigned:
15217 return write_bson_unsigned(
name, j);
15219 case value_t::string:
15220 return write_bson_string(
name, *j.m_value.string);
15222 case value_t::null:
15223 return write_bson_null(
name);
15226 case value_t::discarded:
15240 static std::size_t calc_bson_object_size(
const typename BasicJsonType::object_t&
value)
15242 std::size_t document_size = std::accumulate(
value.begin(),
value.end(),
static_cast<std::size_t
>(0),
15243 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
15245 return result += calc_bson_element_size(el.first, el.second);
15248 return sizeof(std::int32_t) + document_size + 1ul;
15255 void write_bson_object(
const typename BasicJsonType::object_t&
value)
15257 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_object_size(
value)),
true);
15259 for (
const auto& el :
value)
15261 write_bson_element(el.first, el.second);
15264 oa->write_character(to_char_type(0x00));
15271 static constexpr CharType get_cbor_float_prefix(
float )
15273 return to_char_type(0xFA);
15276 static constexpr CharType get_cbor_float_prefix(
double )
15278 return to_char_type(0xFB);
15285 static constexpr CharType get_msgpack_float_prefix(
float )
15287 return to_char_type(0xCA);
15290 static constexpr CharType get_msgpack_float_prefix(
double )
15292 return to_char_type(0xCB);
15300 template<
typename NumberType,
typename std::enable_if<
15301 std::is_floating_point<NumberType>::value,
int>
::type = 0>
15302 void write_number_with_ubjson_prefix(
const NumberType n,
15303 const bool add_prefix,
15304 const bool use_bjdata)
15308 oa->write_character(get_ubjson_float_prefix(n));
15310 write_number(n, use_bjdata);
15314 template<
typename NumberType,
typename std::enable_if<
15315 std::is_unsigned<NumberType>::value,
int>
::type = 0>
15316 void write_number_with_ubjson_prefix(
const NumberType n,
15317 const bool add_prefix,
15318 const bool use_bjdata)
15320 if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
15324 oa->write_character(to_char_type(
'i'));
15326 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
15328 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
15332 oa->write_character(to_char_type(
'U'));
15334 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
15336 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
15340 oa->write_character(to_char_type(
'I'));
15342 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
15344 else if (use_bjdata && n <=
static_cast<uint64_t>((std::numeric_limits<uint16_t>::max)()))
15348 oa->write_character(to_char_type(
'u'));
15350 write_number(
static_cast<std::uint16_t
>(n), use_bjdata);
15352 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
15356 oa->write_character(to_char_type(
'l'));
15358 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
15360 else if (use_bjdata && n <=
static_cast<uint64_t>((std::numeric_limits<uint32_t>::max)()))
15364 oa->write_character(to_char_type(
'm'));
15366 write_number(
static_cast<std::uint32_t
>(n), use_bjdata);
15368 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
15372 oa->write_character(to_char_type(
'L'));
15374 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
15376 else if (use_bjdata && n <= (std::numeric_limits<uint64_t>::max)())
15380 oa->write_character(to_char_type(
'M'));
15382 write_number(
static_cast<std::uint64_t
>(n), use_bjdata);
15388 oa->write_character(to_char_type(
'H'));
15391 const auto number = BasicJsonType(n).dump();
15392 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
15393 for (std::size_t i = 0; i < number.size(); ++i)
15395 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
15401 template <
typename NumberType,
typename std::enable_if <
15402 std::is_signed<NumberType>::value&&
15403 !std::is_floating_point<NumberType>::value,
int >
::type = 0 >
15404 void write_number_with_ubjson_prefix(
const NumberType n,
15405 const bool add_prefix,
15406 const bool use_bjdata)
15408 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
15412 oa->write_character(to_char_type(
'i'));
15414 write_number(
static_cast<std::int8_t
>(n), use_bjdata);
15416 else if (
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::max)()))
15420 oa->write_character(to_char_type(
'U'));
15422 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
15424 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
15428 oa->write_character(to_char_type(
'I'));
15430 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
15432 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::max)())))
15436 oa->write_character(to_char_type(
'u'));
15438 write_number(
static_cast<uint16_t>(n), use_bjdata);
15440 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
15444 oa->write_character(to_char_type(
'l'));
15446 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
15448 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::max)())))
15452 oa->write_character(to_char_type(
'm'));
15454 write_number(
static_cast<uint32_t>(n), use_bjdata);
15456 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
15460 oa->write_character(to_char_type(
'L'));
15462 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
15469 oa->write_character(to_char_type(
'H'));
15472 const auto number = BasicJsonType(n).dump();
15473 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
15474 for (std::size_t i = 0; i < number.size(); ++i)
15476 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
15485 CharType ubjson_prefix(
const BasicJsonType& j,
const bool use_bjdata)
const noexcept
15489 case value_t::null:
15492 case value_t::boolean:
15493 return j.m_value.boolean ?
'T' :
'F';
15495 case value_t::number_integer:
15497 if ((std::numeric_limits<std::int8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
15501 if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
15505 if ((std::numeric_limits<std::int16_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
15509 if (use_bjdata && ((std::numeric_limits<std::uint16_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)()))
15513 if ((std::numeric_limits<std::int32_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
15517 if (use_bjdata && ((std::numeric_limits<std::uint32_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)()))
15521 if ((std::numeric_limits<std::int64_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
15529 case value_t::number_unsigned:
15531 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
15535 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
15539 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
15543 if (use_bjdata && j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint16_t>::max)()))
15547 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
15551 if (use_bjdata && j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint32_t>::max)()))
15555 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
15559 if (use_bjdata && j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
15567 case value_t::number_float:
15568 return get_ubjson_float_prefix(j.m_value.number_float);
15570 case value_t::string:
15573 case value_t::array:
15574 case value_t::binary:
15577 case value_t::object:
15580 case value_t::discarded:
15586 static constexpr CharType get_ubjson_float_prefix(
float )
15591 static constexpr CharType get_ubjson_float_prefix(
double )
15599 bool write_bjdata_ndarray(
const typename BasicJsonType::object_t&
value,
const bool use_count,
const bool use_type)
15601 std::map<string_t, CharType> bjdtype = {{
"uint8",
'U'}, {
"int8",
'i'}, {
"uint16",
'u'}, {
"int16",
'I'},
15602 {
"uint32",
'm'}, {
"int32",
'l'}, {
"uint64",
'M'}, {
"int64",
'L'}, {
"single",
'd'}, {
"double",
'D'}, {
"char",
'C'}
15605 string_t key =
"_ArrayType_";
15606 auto it = bjdtype.find(
static_cast<string_t
>(
value.at(key)));
15607 if (it == bjdtype.end())
15611 CharType dtype = it->second;
15613 key =
"_ArraySize_";
15614 std::size_t
len = (
value.at(key).empty() ? 0 : 1);
15615 for (
const auto& el :
value.at(key))
15617 len *=
static_cast<std::size_t
>(el.m_value.number_unsigned);
15620 key =
"_ArrayData_";
15626 oa->write_character(
'[');
15627 oa->write_character(
'$');
15628 oa->write_character(dtype);
15629 oa->write_character(
'#');
15631 key =
"_ArraySize_";
15632 write_ubjson(
value.at(key), use_count, use_type,
true,
true);
15634 key =
"_ArrayData_";
15635 if (dtype ==
'U' || dtype ==
'C')
15637 for (
const auto& el :
value.at(key))
15639 write_number(
static_cast<std::uint8_t
>(el.m_value.number_unsigned),
true);
15642 else if (dtype ==
'i')
15644 for (
const auto& el :
value.at(key))
15646 write_number(
static_cast<std::int8_t
>(el.m_value.number_integer),
true);
15649 else if (dtype ==
'u')
15651 for (
const auto& el :
value.at(key))
15653 write_number(
static_cast<std::uint16_t
>(el.m_value.number_unsigned),
true);
15656 else if (dtype ==
'I')
15658 for (
const auto& el :
value.at(key))
15660 write_number(
static_cast<std::int16_t
>(el.m_value.number_integer),
true);
15663 else if (dtype ==
'm')
15665 for (
const auto& el :
value.at(key))
15667 write_number(
static_cast<std::uint32_t
>(el.m_value.number_unsigned),
true);
15670 else if (dtype ==
'l')
15672 for (
const auto& el :
value.at(key))
15674 write_number(
static_cast<std::int32_t
>(el.m_value.number_integer),
true);
15677 else if (dtype ==
'M')
15679 for (
const auto& el :
value.at(key))
15681 write_number(
static_cast<std::uint64_t
>(el.m_value.number_unsigned),
true);
15684 else if (dtype ==
'L')
15686 for (
const auto& el :
value.at(key))
15688 write_number(
static_cast<std::int64_t
>(el.m_value.number_integer),
true);
15691 else if (dtype ==
'd')
15693 for (
const auto& el :
value.at(key))
15695 write_number(
static_cast<float>(el.m_value.number_float),
true);
15698 else if (dtype ==
'D')
15700 for (
const auto& el :
value.at(key))
15702 write_number(
static_cast<double>(el.m_value.number_float),
true);
15725 template<
typename NumberType>
15726 void write_number(
const NumberType n,
const bool OutputIsLittleEndian =
false)
15729 std::array<CharType,
sizeof(NumberType)> vec{};
15730 std::memcpy(vec.data(), &n,
sizeof(NumberType));
15733 if (is_little_endian != OutputIsLittleEndian)
15739 oa->write_characters(vec.data(),
sizeof(NumberType));
15742 void write_compact_float(
const number_float_t n, detail::input_format_t
format)
15745#pragma GCC diagnostic push
15746#pragma GCC diagnostic ignored "-Wfloat-equal"
15748 if (
static_cast<double>(n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
15749 static_cast<double>(n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
15750 static_cast<double>(
static_cast<float>(n)) ==
static_cast<double>(n))
15752 oa->write_character(
format == detail::input_format_t::cbor
15753 ? get_cbor_float_prefix(
static_cast<float>(n))
15754 : get_msgpack_float_prefix(static_cast<float>(n)));
15755 write_number(
static_cast<float>(n));
15759 oa->write_character(
format == detail::input_format_t::cbor
15760 ? get_cbor_float_prefix(n)
15761 : get_msgpack_float_prefix(n));
15765#pragma GCC diagnostic pop
15774 template <
typename C = CharType,
15775 enable_if_t < std::is_signed<C>::value && std::is_signed<char>::value > * =
nullptr >
15776 static constexpr CharType to_char_type(std::uint8_t
x)
noexcept
15778 return *
reinterpret_cast<char*
>(&
x);
15781 template <
typename C = CharType,
15782 enable_if_t < std::is_signed<C>::value && std::is_unsigned<char>::value > * =
nullptr >
15783 static CharType to_char_type(std::uint8_t
x)
noexcept
15785 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
15786 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
15788 std::memcpy(&
result, &
x,
sizeof(
x));
15792 template<
typename C = CharType,
15793 enable_if_t<std::is_unsigned<C>::value>* =
nullptr>
15794 static constexpr CharType to_char_type(std::uint8_t
x)
noexcept
15799 template <
typename InputCharType,
typename C = CharType,
15801 std::is_signed<C>::value &&
15802 std::is_signed<char>::value &&
15803 std::is_same<char, typename std::remove_cv<InputCharType>::type>
::value
15805 static constexpr CharType to_char_type(InputCharType
x)
noexcept
15812 const bool is_little_endian = little_endianness();
15815 output_adapter_t<CharType> oa =
nullptr;
15825#include <algorithm>
15835#include <type_traits>
15846#include <type_traits>
15878template<
typename Target,
typename Source>
15879Target reinterpret_bits(
const Source
source)
15881 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
15890 static constexpr int kPrecision = 64;
15892 std::uint64_t
f = 0;
15895 constexpr diyfp(std::uint64_t f_,
int e_) noexcept :
f(f_), e(e_) {}
15901 static diyfp sub(
const diyfp&
x,
const diyfp&
y)
noexcept
15906 return {
x.f -
y.f,
x.e};
15913 static diyfp mul(
const diyfp&
x,
const diyfp&
y)
noexcept
15915 static_assert(kPrecision == 64,
"internal error");
15940 const std::uint64_t u_lo =
x.f & 0xFFFFFFFFu;
15941 const std::uint64_t u_hi =
x.f >> 32u;
15942 const std::uint64_t v_lo =
y.f & 0xFFFFFFFFu;
15943 const std::uint64_t v_hi =
y.f >> 32u;
15945 const std::uint64_t p0 = u_lo * v_lo;
15946 const std::uint64_t p1 = u_lo * v_hi;
15947 const std::uint64_t p2 = u_hi * v_lo;
15948 const std::uint64_t p3 = u_hi * v_hi;
15950 const std::uint64_t p0_hi = p0 >> 32u;
15951 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
15952 const std::uint64_t p1_hi = p1 >> 32u;
15953 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
15954 const std::uint64_t p2_hi = p2 >> 32u;
15956 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
15967 Q += std::uint64_t{1} << (64u - 32u - 1u);
15969 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
15971 return {h,
x.e +
y.e + 64};
15982 while ((
x.f >> 63u) == 0)
15995 static diyfp normalize_to(
const diyfp&
x,
const int target_exponent)
noexcept
15997 const int delta =
x.e - target_exponent;
16002 return {
x.f << delta, target_exponent};
16019template<
typename FloatType>
16020boundaries compute_boundaries(FloatType
value)
16032 static_assert(std::numeric_limits<FloatType>::is_iec559,
16033 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
16035 constexpr int kPrecision = std::numeric_limits<FloatType>::digits;
16036 constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
16037 constexpr int kMinExp = 1 - kBias;
16038 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
16040 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
16042 const auto bits =
static_cast<std::uint64_t
>(reinterpret_bits<bits_type>(
value));
16043 const std::uint64_t E = bits >> (kPrecision - 1);
16044 const std::uint64_t F = bits & (kHiddenBit - 1);
16046 const bool is_denormal = E == 0;
16047 const diyfp
v = is_denormal
16048 ? diyfp(F, kMinExp)
16049 : diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
16072 const bool lower_boundary_is_closer = F == 0 && E > 1;
16073 const diyfp m_plus = diyfp(2 *
v.f + 1,
v.e - 1);
16074 const diyfp m_minus = lower_boundary_is_closer
16075 ? diyfp(4 *
v.f - 1,
v.e - 2)
16076 : diyfp(2 *
v.f - 1,
v.e - 1);
16079 const diyfp w_plus = diyfp::normalize(m_plus);
16082 const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.e);
16084 return {diyfp::normalize(
v), w_minus, w_plus};
16142constexpr int kAlpha = -60;
16143constexpr int kGamma = -32;
16159inline cached_power get_cached_power_for_binary_exponent(
int e)
16211 constexpr int kCachedPowersMinDecExp = -300;
16212 constexpr int kCachedPowersDecStep = 8;
16214 static constexpr std::array<cached_power, 79> kCachedPowers =
16217 { 0xAB70FE17C79AC6CA, -1060, -300 },
16218 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
16219 { 0xBE5691EF416BD60C, -1007, -284 },
16220 { 0x8DD01FAD907FFC3C, -980, -276 },
16221 { 0xD3515C2831559A83, -954, -268 },
16222 { 0x9D71AC8FADA6C9B5, -927, -260 },
16223 { 0xEA9C227723EE8BCB, -901, -252 },
16224 { 0xAECC49914078536D, -874, -244 },
16225 { 0x823C12795DB6CE57, -847, -236 },
16226 { 0xC21094364DFB5637, -821, -228 },
16227 { 0x9096EA6F3848984F, -794, -220 },
16228 { 0xD77485CB25823AC7, -768, -212 },
16229 { 0xA086CFCD97BF97F4, -741, -204 },
16230 { 0xEF340A98172AACE5, -715, -196 },
16231 { 0xB23867FB2A35B28E, -688, -188 },
16232 { 0x84C8D4DFD2C63F3B, -661, -180 },
16233 { 0xC5DD44271AD3CDBA, -635, -172 },
16234 { 0x936B9FCEBB25C996, -608, -164 },
16235 { 0xDBAC6C247D62A584, -582, -156 },
16236 { 0xA3AB66580D5FDAF6, -555, -148 },
16237 { 0xF3E2F893DEC3F126, -529, -140 },
16238 { 0xB5B5ADA8AAFF80B8, -502, -132 },
16239 { 0x87625F056C7C4A8B, -475, -124 },
16240 { 0xC9BCFF6034C13053, -449, -116 },
16241 { 0x964E858C91BA2655, -422, -108 },
16242 { 0xDFF9772470297EBD, -396, -100 },
16243 { 0xA6DFBD9FB8E5B88F, -369, -92 },
16244 { 0xF8A95FCF88747D94, -343, -84 },
16245 { 0xB94470938FA89BCF, -316, -76 },
16246 { 0x8A08F0F8BF0F156B, -289, -68 },
16247 { 0xCDB02555653131B6, -263, -60 },
16248 { 0x993FE2C6D07B7FAC, -236, -52 },
16249 { 0xE45C10C42A2B3B06, -210, -44 },
16250 { 0xAA242499697392D3, -183, -36 },
16251 { 0xFD87B5F28300CA0E, -157, -28 },
16252 { 0xBCE5086492111AEB, -130, -20 },
16253 { 0x8CBCCC096F5088CC, -103, -12 },
16254 { 0xD1B71758E219652C, -77, -4 },
16255 { 0x9C40000000000000, -50, 4 },
16256 { 0xE8D4A51000000000, -24, 12 },
16257 { 0xAD78EBC5AC620000, 3, 20 },
16258 { 0x813F3978F8940984, 30, 28 },
16259 { 0xC097CE7BC90715B3, 56, 36 },
16260 { 0x8F7E32CE7BEA5C70, 83, 44 },
16261 { 0xD5D238A4ABE98068, 109, 52 },
16262 { 0x9F4F2726179A2245, 136, 60 },
16263 { 0xED63A231D4C4FB27, 162, 68 },
16264 { 0xB0DE65388CC8ADA8, 189, 76 },
16265 { 0x83C7088E1AAB65DB, 216, 84 },
16266 { 0xC45D1DF942711D9A, 242, 92 },
16267 { 0x924D692CA61BE758, 269, 100 },
16268 { 0xDA01EE641A708DEA, 295, 108 },
16269 { 0xA26DA3999AEF774A, 322, 116 },
16270 { 0xF209787BB47D6B85, 348, 124 },
16271 { 0xB454E4A179DD1877, 375, 132 },
16272 { 0x865B86925B9BC5C2, 402, 140 },
16273 { 0xC83553C5C8965D3D, 428, 148 },
16274 { 0x952AB45CFA97A0B3, 455, 156 },
16275 { 0xDE469FBD99A05FE3, 481, 164 },
16276 { 0xA59BC234DB398C25, 508, 172 },
16277 { 0xF6C69A72A3989F5C, 534, 180 },
16278 { 0xB7DCBF5354E9BECE, 561, 188 },
16279 { 0x88FCF317F22241E2, 588, 196 },
16280 { 0xCC20CE9BD35C78A5, 614, 204 },
16281 { 0x98165AF37B2153DF, 641, 212 },
16282 { 0xE2A0B5DC971F303A, 667, 220 },
16283 { 0xA8D9D1535CE3B396, 694, 228 },
16284 { 0xFB9B7CD9A4A7443C, 720, 236 },
16285 { 0xBB764C4CA7A44410, 747, 244 },
16286 { 0x8BAB8EEFB6409C1A, 774, 252 },
16287 { 0xD01FEF10A657842C, 800, 260 },
16288 { 0x9B10A4E5E9913129, 827, 268 },
16289 { 0xE7109BFBA19C0C9D, 853, 276 },
16290 { 0xAC2820D9623BF429, 880, 284 },
16291 { 0x80444B5E7AA7CF85, 907, 292 },
16292 { 0xBF21E44003ACDD2D, 933, 300 },
16293 { 0x8E679C2F5E44FF8F, 960, 308 },
16294 { 0xD433179D9C8CB841, 986, 316 },
16295 { 0x9E19DB92B4E31BA9, 1013, 324 },
16305 const int f = kAlpha - e - 1;
16306 const int k = (
f * 78913) / (1 << 18) +
static_cast<int>(
f > 0);
16308 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
16312 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(
index)];
16323inline int find_largest_pow10(
const std::uint32_t n, std::uint32_t& pow10)
16326 if (n >= 1000000000)
16328 pow10 = 1000000000;
16332 if (n >= 100000000)
16377inline void grisu2_round(
char*
buf,
int len, std::uint64_t dist, std::uint64_t delta,
16378 std::uint64_t rest, std::uint64_t ten_k)
16405 && delta - rest >= ten_k
16406 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
16418inline void grisu2_digit_gen(
char*
buffer,
int&
length,
int& decimal_exponent,
16419 diyfp M_minus, diyfp
w, diyfp M_plus)
16421 static_assert(kAlpha >= -60,
"internal error");
16422 static_assert(kGamma <= -32,
"internal error");
16439 std::uint64_t delta = diyfp::sub(M_plus, M_minus).f;
16440 std::uint64_t dist = diyfp::sub(M_plus,
w ).f;
16449 const diyfp one(std::uint64_t{1} << -M_plus.e, M_plus.e);
16451 auto p1 =
static_cast<std::uint32_t
>(M_plus.f >> -one.e);
16452 std::uint64_t p2 = M_plus.f & (one.f - 1);
16460 std::uint32_t pow10{};
16461 const int k = find_largest_pow10(p1, pow10);
16488 const std::uint32_t d = p1 / pow10;
16489 const std::uint32_t
r = p1 % pow10;
16514 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
16519 decimal_exponent += n;
16530 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
16531 grisu2_round(
buffer,
length, dist, delta, rest, ten_n);
16592 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
16594 const std::uint64_t d = p2 >> -one.e;
16595 const std::uint64_t
r = p2 & (one.f - 1);
16627 decimal_exponent -= m;
16635 const std::uint64_t ten_m = one.f;
16659inline void grisu2(
char*
buf,
int&
len,
int& decimal_exponent,
16660 diyfp m_minus, diyfp
v, diyfp m_plus)
16674 const cached_power cached = get_cached_power_for_binary_exponent(m_plus.e);
16676 const diyfp c_minus_k(cached.f, cached.e);
16679 const diyfp
w = diyfp::mul(
v, c_minus_k);
16680 const diyfp w_minus = diyfp::mul(m_minus, c_minus_k);
16681 const diyfp w_plus = diyfp::mul(m_plus, c_minus_k);
16704 const diyfp M_minus(w_minus.f + 1, w_minus.e);
16705 const diyfp M_plus (w_plus.f - 1, w_plus.e );
16707 decimal_exponent = -cached.k;
16709 grisu2_digit_gen(
buf,
len, decimal_exponent, M_minus,
w, M_plus);
16717template<
typename FloatType>
16719void grisu2(
char*
buf,
int&
len,
int& decimal_exponent, FloatType
value)
16721 static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3,
16722 "internal error: not enough precision");
16744 const boundaries
w = compute_boundaries(
static_cast<double>(
value));
16746 const boundaries
w = compute_boundaries(
value);
16749 grisu2(
buf,
len, decimal_exponent,
w.minus,
w.w,
w.plus);
16759inline char* append_exponent(
char*
buf,
int e)
16774 auto k =
static_cast<std::uint32_t
>(e);
16780 *
buf++ =
static_cast<char>(
'0' + k);
16784 *
buf++ =
static_cast<char>(
'0' + k / 10);
16786 *
buf++ =
static_cast<char>(
'0' + k);
16790 *
buf++ =
static_cast<char>(
'0' + k / 100);
16792 *
buf++ =
static_cast<char>(
'0' + k / 10);
16794 *
buf++ =
static_cast<char>(
'0' + k);
16811inline char* format_buffer(
char*
buf,
int len,
int decimal_exponent,
16812 int min_exp,
int max_exp)
16818 const int n =
len + decimal_exponent;
16824 if (k <= n && n <= max_exp)
16829 std::memset(
buf + k,
'0',
static_cast<size_t>(n) -
static_cast<size_t>(k));
16833 return buf + (
static_cast<size_t>(n) + 2);
16836 if (0 < n && n <= max_exp)
16843 std::memmove(
buf + (
static_cast<size_t>(n) + 1),
buf + n,
static_cast<size_t>(k) -
static_cast<size_t>(n));
16845 return buf + (
static_cast<size_t>(k) + 1U);
16848 if (min_exp < n && n <= 0)
16853 std::memmove(
buf + (2 +
static_cast<size_t>(-n)),
buf,
static_cast<size_t>(k));
16856 std::memset(
buf + 2,
'0',
static_cast<size_t>(-n));
16857 return buf + (2U +
static_cast<size_t>(-n) +
static_cast<size_t>(k));
16872 std::memmove(
buf + 2,
buf + 1,
static_cast<size_t>(k) - 1);
16874 buf += 1 +
static_cast<size_t>(k);
16878 return append_exponent(
buf, n - 1);
16893template<
typename FloatType>
16896char* to_chars(
char*
first, const
char* last, FloatType
value)
16898 static_cast<void>(last);
16902 if (std::signbit(
value))
16909#pragma GCC diagnostic push
16910#pragma GCC diagnostic ignored "-Wfloat-equal"
16921#pragma GCC diagnostic pop
16924 JSON_ASSERT(last -
first >= std::numeric_limits<FloatType>::max_digits10);
16931 int decimal_exponent = 0;
16934 JSON_ASSERT(
len <= std::numeric_limits<FloatType>::max_digits10);
16937 constexpr int kMinExp = -4;
16939 constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
16942 JSON_ASSERT(last -
first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
16943 JSON_ASSERT(last -
first >= std::numeric_limits<FloatType>::max_digits10 + 6);
16945 return dtoa_impl::format_buffer(
first,
len, decimal_exponent, kMinExp, kMaxExp);
16982template<
typename BasicJsonType>
16985 using string_t =
typename BasicJsonType::string_t;
16986 using number_float_t =
typename BasicJsonType::number_float_t;
16987 using number_integer_t =
typename BasicJsonType::number_integer_t;
16988 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
16989 using binary_char_t =
typename BasicJsonType::binary_t::value_type;
16990 static constexpr std::uint8_t UTF8_ACCEPT = 0;
16991 static constexpr std::uint8_t UTF8_REJECT = 1;
17002 ,
loc(
std::localeconv())
17040 const bool pretty_print,
17042 const unsigned int indent_step,
17043 const unsigned int current_indent = 0)
17045 switch (
val.m_type)
17049 if (
val.m_value.object->empty())
17051 o->write_characters(
"{}", 2);
17057 o->write_characters(
"{\n", 2);
17060 const auto new_indent = current_indent + indent_step;
17067 auto i =
val.m_value.object->cbegin();
17068 for (std::size_t cnt = 0; cnt <
val.m_value.object->size() - 1; ++cnt, ++i)
17071 o->write_character(
'\"');
17073 o->write_characters(
"\": ", 3);
17075 o->write_characters(
",\n", 2);
17082 o->write_character(
'\"');
17084 o->write_characters(
"\": ", 3);
17087 o->write_character(
'\n');
17088 o->write_characters(
indent_string.c_str(), current_indent);
17089 o->write_character(
'}');
17093 o->write_character(
'{');
17096 auto i =
val.m_value.object->cbegin();
17097 for (std::size_t cnt = 0; cnt <
val.m_value.object->size() - 1; ++cnt, ++i)
17099 o->write_character(
'\"');
17101 o->write_characters(
"\":", 2);
17103 o->write_character(
',');
17109 o->write_character(
'\"');
17111 o->write_characters(
"\":", 2);
17114 o->write_character(
'}');
17122 if (
val.m_value.array->empty())
17124 o->write_characters(
"[]", 2);
17130 o->write_characters(
"[\n", 2);
17133 const auto new_indent = current_indent + indent_step;
17140 for (
auto i =
val.m_value.array->cbegin();
17141 i !=
val.m_value.array->cend() - 1; ++i)
17145 o->write_characters(
",\n", 2);
17153 o->write_character(
'\n');
17154 o->write_characters(
indent_string.c_str(), current_indent);
17155 o->write_character(
']');
17159 o->write_character(
'[');
17162 for (
auto i =
val.m_value.array->cbegin();
17163 i !=
val.m_value.array->cend() - 1; ++i)
17166 o->write_character(
',');
17173 o->write_character(
']');
17181 o->write_character(
'\"');
17183 o->write_character(
'\"');
17191 o->write_characters(
"{\n", 2);
17194 const auto new_indent = current_indent + indent_step;
17202 o->write_characters(
"\"bytes\": [", 10);
17204 if (!
val.m_value.binary->empty())
17206 for (
auto i =
val.m_value.binary->cbegin();
17207 i !=
val.m_value.binary->cend() - 1; ++i)
17210 o->write_characters(
", ", 2);
17212 dump_integer(
val.m_value.binary->back());
17215 o->write_characters(
"],\n", 3);
17218 o->write_characters(
"\"subtype\": ", 11);
17219 if (
val.m_value.binary->has_subtype())
17221 dump_integer(
val.m_value.binary->subtype());
17225 o->write_characters(
"null", 4);
17227 o->write_character(
'\n');
17228 o->write_characters(
indent_string.c_str(), current_indent);
17229 o->write_character(
'}');
17233 o->write_characters(
"{\"bytes\":[", 10);
17235 if (!
val.m_value.binary->empty())
17237 for (
auto i =
val.m_value.binary->cbegin();
17238 i !=
val.m_value.binary->cend() - 1; ++i)
17241 o->write_character(
',');
17243 dump_integer(
val.m_value.binary->back());
17246 o->write_characters(
"],\"subtype\":", 12);
17247 if (
val.m_value.binary->has_subtype())
17249 dump_integer(
val.m_value.binary->subtype());
17250 o->write_character(
'}');
17254 o->write_characters(
"null}", 5);
17262 if (
val.m_value.boolean)
17264 o->write_characters(
"true", 4);
17268 o->write_characters(
"false", 5);
17275 dump_integer(
val.m_value.number_integer);
17281 dump_integer(
val.m_value.number_unsigned);
17287 dump_float(
val.m_value.number_float);
17293 o->write_characters(
"<discarded>", 11);
17299 o->write_characters(
"null", 4);
17325 std::uint32_t codepoint{};
17333 for (std::size_t i = 0; i < s.size(); ++i)
17335 const auto byte =
static_cast<std::uint8_t
>(s[i]);
17337 switch (decode(
state, codepoint,
byte))
17396 if ((codepoint <= 0x1F) || (
ensure_ascii && (codepoint >= 0x7F)))
17398 if (codepoint <= 0xFFFF)
17402 static_cast<std::uint16_t
>(codepoint)));
17408 static_cast<void>((std::snprintf)(
string_buffer.data() +
bytes, 13,
"\\u%04x\\u%04x",
17409 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
17410 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu))));
17478 string_buffer[
bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type(
'\xEF');
17479 string_buffer[
bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type(
'\xBF');
17480 string_buffer[
bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type(
'\xBD');
17498 state = UTF8_ACCEPT;
17554 o->write_characters(
"\\ufffd", 6);
17558 o->write_characters(
"\xEF\xBF\xBD", 3);
17578 inline unsigned int count_digits(number_unsigned_t
x)
noexcept
17580 unsigned int n_digits = 1;
17589 return n_digits + 1;
17593 return n_digits + 2;
17597 return n_digits + 3;
17609 static std::string hex_bytes(std::uint8_t
byte)
17611 std::string
result =
"FF";
17612 constexpr const char* nibble_to_hex =
"0123456789ABCDEF";
17613 result[0] = nibble_to_hex[
byte / 16];
17614 result[1] = nibble_to_hex[
byte % 16];
17619 template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value,
int> = 0>
17620 bool is_negative_number(NumberType
x)
17625 template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value,
int > = 0 >
17626 bool is_negative_number(NumberType )
17641 std::is_integral<NumberType>::value ||
17642 std::is_same<NumberType, number_unsigned_t>::value ||
17643 std::is_same<NumberType, number_integer_t>::value ||
17644 std::is_same<NumberType, binary_char_t>::value,
17646 void dump_integer(NumberType
x)
17648 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
17651 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
17652 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
17653 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
17654 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
17655 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
17656 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
17657 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
17658 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
17659 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
17660 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
17667 o->write_character(
'0');
17674 number_unsigned_t abs_value;
17676 unsigned int n_chars{};
17678 if (is_negative_number(
x))
17681 abs_value = remove_sign(
static_cast<number_integer_t
>(
x));
17684 n_chars = 1 + count_digits(abs_value);
17688 abs_value =
static_cast<number_unsigned_t
>(
x);
17689 n_chars = count_digits(abs_value);
17697 buffer_ptr += n_chars;
17701 while (abs_value >= 100)
17703 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
17705 *(--buffer_ptr) = digits_to_99[digits_index][1];
17706 *(--buffer_ptr) = digits_to_99[digits_index][0];
17709 if (abs_value >= 10)
17711 const auto digits_index =
static_cast<unsigned>(abs_value);
17712 *(--buffer_ptr) = digits_to_99[digits_index][1];
17713 *(--buffer_ptr) = digits_to_99[digits_index][0];
17717 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
17731 void dump_float(number_float_t
x)
17734 if (!std::isfinite(
x))
17736 o->write_characters(
"null", 4);
17745 static constexpr bool is_ieee_single_or_double
17746 = (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 24 && std::numeric_limits<number_float_t>::max_exponent == 128) ||
17747 (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 53 && std::numeric_limits<number_float_t>::max_exponent == 1024);
17749 dump_float(
x, std::integral_constant<bool, is_ieee_single_or_double>());
17752 void dump_float(number_float_t
x, std::true_type )
17755 auto*
end = ::nlohmann::detail::to_chars(begin, begin +
number_buffer.size(),
x);
17757 o->write_characters(begin,
static_cast<size_t>(
end - begin));
17760 void dump_float(number_float_t
x, std::false_type )
17763 static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
17798 const bool value_is_int_like =
17802 return c ==
'.' || c ==
'e';
17805 if (value_is_int_like)
17807 o->write_characters(
".0", 2);
17832 static std::uint8_t decode(std::uint8_t&
state, std::uint32_t& codep,
const std::uint8_t
byte)
noexcept
17834 static const std::array<std::uint8_t, 400> utf8d =
17837 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
17838 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
17839 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
17840 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
17841 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
17842 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
17843 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
17844 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
17845 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
17846 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
17847 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1,
17848 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
17849 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1,
17850 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
17855 const std::uint8_t
type = utf8d[
byte];
17857 codep = (
state != UTF8_ACCEPT)
17858 ? (
byte & 0x3fu) | (codep << 6u)
17861 std::size_t
index = 256u +
static_cast<size_t>(
state) * 16u +
static_cast<size_t>(
type);
17872 number_unsigned_t remove_sign(number_unsigned_t
x)
17887 inline number_unsigned_t remove_sign(number_integer_t
x)
noexcept
17889 JSON_ASSERT(
x < 0 &&
x < (std::numeric_limits<number_integer_t>::max)());
17890 return static_cast<number_unsigned_t
>(-(
x + 1)) + 1;
17895 output_adapter_t<char> o =
nullptr;
17928#include <functional>
17929#include <initializer_list>
17932#include <stdexcept>
17933#include <type_traits>
17945template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
17946 class Allocator = std::allocator<std::pair<const Key, T>>>
17951 using Container = std::vector<std::pair<const Key, T>, Allocator>;
17956#ifdef JSON_HAS_CPP_14
17966 template <
class It>
17969 ordered_map(std::initializer_list<value_type> init,
const Allocator& alloc = Allocator() )
17974 for (
auto it = this->begin(); it != this->
end(); ++it)
17976 if (m_compare(it->first, key))
17978 return {it,
false};
17981 Container::emplace_back(key, t);
17982 return {--this->
end(),
true};
17997 for (
auto it = this->begin(); it != this->
end(); ++it)
17999 if (m_compare(it->first, key))
18005 JSON_THROW(std::out_of_range(
"key not found"));
18008 const T&
at(
const Key& key)
const
18010 for (
auto it = this->begin(); it != this->
end(); ++it)
18012 if (m_compare(it->first, key))
18018 JSON_THROW(std::out_of_range(
"key not found"));
18023 for (
auto it = this->begin(); it != this->
end(); ++it)
18025 if (m_compare(it->first, key))
18028 for (
auto next = it; ++next != this->
end(); ++it)
18033 Container::pop_back();
18042 return erase(pos, std::next(pos));
18047 const auto elements_affected = std::distance(
first, last);
18048 const auto offset = std::distance(Container::begin(),
first);
18070 for (
auto it =
first; std::next(it, elements_affected) != Container::end(); ++it)
18081 Container::resize(this->
size() -
static_cast<size_type>(elements_affected));
18090 return Container::begin() +
offset;
18095 for (
auto it = this->begin(); it != this->
end(); ++it)
18097 if (m_compare(it->first, key))
18107 for (
auto it = this->begin(); it != this->
end(); ++it)
18109 if (m_compare(it->first, key))
18114 return Container::end();
18119 for (
auto it = this->begin(); it != this->
end(); ++it)
18121 if (m_compare(it->first, key))
18126 return Container::end();
18136 for (
auto it = this->begin(); it != this->
end(); ++it)
18138 if (m_compare(it->first,
value.first))
18140 return {it,
false};
18143 Container::push_back(
value);
18144 return {--this->
end(),
true};
18147 template<
typename InputIt>
18148 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
18151 template<
typename InputIt,
typename = require_input_iter<InputIt>>
18154 for (
auto it =
first; it != last; ++it)
18167#if defined(JSON_HAS_CPP_17)
18169 #include <string_view>
18205 friend class ::nlohmann::json_pointer;
18209 template<
typename BasicJsonType,
typename InputType>
18210 friend class ::nlohmann::detail::parser;
18211 friend ::nlohmann::detail::serializer<basic_json>;
18212 template<
typename BasicJsonType>
18213 friend class ::nlohmann::detail::iter_impl;
18214 template<
typename BasicJsonType,
typename CharType>
18215 friend class ::nlohmann::detail::binary_writer;
18216 template<
typename BasicJsonType,
typename InputType,
typename SAX>
18217 friend class ::nlohmann::detail::binary_reader;
18218 template<
typename BasicJsonType>
18219 friend class ::nlohmann::detail::json_sax_dom_parser;
18220 template<
typename BasicJsonType>
18221 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
18222 friend class ::nlohmann::detail::exception;
18231 template<
typename InputAdapterType>
18232 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
18233 InputAdapterType adapter,
18234 detail::parser_callback_t<basic_json>cb =
nullptr,
18235 const bool allow_exceptions =
true,
18236 const bool ignore_comments =
false
18239 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(
std::move(adapter),
18240 std::move(cb), allow_exceptions, ignore_comments);
18244 using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t;
18245 template<
typename BasicJsonType>
18247 template<
typename BasicJsonType>
18249 template<
typename Iterator>
18250 using iteration_proxy = ::nlohmann::detail::iteration_proxy<Iterator>;
18253 template<
typename CharType>
18254 using output_adapter_t = ::nlohmann::detail::output_adapter_t<CharType>;
18256 template<
typename InputType>
18258 template<
typename CharType>
using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
18267 template<
typename T,
typename SFINAE>
18276 using input_format_t = detail::input_format_t;
18324 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
18326 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
18354 result[
"copyright"] =
"(C) 2013-2022 Niels Lohmann";
18355 result[
"name"] =
"JSON for Modern C++";
18356 result[
"url"] =
"https://github.com/nlohmann/json";
18357 result[
"version"][
"string"] =
18366 result[
"platform"] =
"win32";
18367#elif defined __linux__
18368 result[
"platform"] =
"linux";
18369#elif defined __APPLE__
18370 result[
"platform"] =
"apple";
18371#elif defined __unix__
18372 result[
"platform"] =
"unix";
18374 result[
"platform"] =
"unknown";
18377#if defined(__ICC) || defined(__INTEL_COMPILER)
18378 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
18379#elif defined(__clang__)
18380 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
18381#elif defined(__GNUC__) || defined(__GNUG__)
18383 std::to_string(__GNUC__),
'.',
18384 std::to_string(__GNUC_MINOR__),
'.',
18385 std::to_string(__GNUC_PATCHLEVEL__))
18388#elif defined(__HP_cc) || defined(__HP_aCC)
18389 result[
"compiler"] =
"hp"
18390#elif defined(__IBMCPP__)
18391 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
18392#elif defined(_MSC_VER)
18393 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
18394#elif defined(__PGI)
18395 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
18396#elif defined(__SUNPRO_CC)
18397 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
18399 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
18403#if defined(_MSVC_LANG)
18404 result[
"compiler"][
"c++"] = std::to_string(_MSVC_LANG);
18405#elif defined(__cplusplus)
18406 result[
"compiler"][
"c++"] = std::to_string(__cplusplus);
18408 result[
"compiler"][
"c++"] =
"unknown";
18427#if defined(JSON_HAS_CPP_14)
18440 AllocatorType<std::pair<
const StringType,
18445 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
18480 template<
typename T,
typename... Args>
18482 static T* create(Args&& ... args)
18484 AllocatorType<T> alloc;
18485 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
18487 auto deleter = [&](T * obj)
18489 AllocatorTraits::deallocate(alloc, obj, 1);
18491 std::unique_ptr<T,
decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
18492 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
18494 return obj.release();
18547 json_value() =
default;
18561 case value_t::object:
18563 object = create<object_t>();
18567 case value_t::array:
18569 array = create<array_t>();
18573 case value_t::string:
18575 string = create<string_t>(
"");
18579 case value_t::binary:
18581 binary = create<binary_t>();
18585 case value_t::boolean:
18587 boolean =
static_cast<boolean_t>(
false);
18591 case value_t::number_integer:
18597 case value_t::number_unsigned:
18603 case value_t::number_float:
18609 case value_t::null:
18615 case value_t::discarded:
18660 if (t == value_t::array || t == value_t::object)
18663 std::vector<basic_json> stack;
18666 if (t == value_t::array)
18673 stack.reserve(
object->size());
18674 for (
auto&& it : *
object)
18680 while (!stack.empty())
18683 basic_json current_item(
std::move(stack.back()));
18688 if (current_item.is_array())
18690 std::move(current_item.m_value.array->begin(), current_item.m_value.array->end(), std::back_inserter(stack));
18692 current_item.m_value.array->clear();
18694 else if (current_item.is_object())
18701 current_item.m_value.object->clear();
18711 case value_t::object:
18713 AllocatorType<object_t> alloc;
18714 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
object);
18715 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
object, 1);
18719 case value_t::array:
18721 AllocatorType<array_t> alloc;
18722 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
array);
18723 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
array, 1);
18727 case value_t::string:
18729 AllocatorType<string_t> alloc;
18730 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
string);
18731 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
18735 case value_t::binary:
18737 AllocatorType<binary_t> alloc;
18738 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
binary);
18739 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
binary, 1);
18743 case value_t::null:
18744 case value_t::boolean:
18745 case value_t::number_integer:
18746 case value_t::number_unsigned:
18747 case value_t::number_float:
18748 case value_t::discarded:
18776 void assert_invariant(
bool check_parents =
true) const noexcept
18783#if JSON_DIAGNOSTICS
18789 return j.m_parent ==
this;
18794 static_cast<void>(check_parents);
18799#if JSON_DIAGNOSTICS
18802 case value_t::array:
18806 element.m_parent =
this;
18811 case value_t::object:
18815 element.second.m_parent =
this;
18820 case value_t::null:
18821 case value_t::string:
18822 case value_t::boolean:
18823 case value_t::number_integer:
18824 case value_t::number_unsigned:
18825 case value_t::number_float:
18826 case value_t::binary:
18827 case value_t::discarded:
18836#if JSON_DIAGNOSTICS
18839 (it + i)->m_parent =
this;
18842 static_cast<void>(count_set_parents);
18847 reference set_parent(
reference j, std::size_t old_capacity =
static_cast<std::size_t
>(-1))
18849#if JSON_DIAGNOSTICS
18850 if (old_capacity !=
static_cast<std::size_t
>(-1))
18864#ifdef JSON_HEDLEY_MSVC_VERSION
18865#pragma warning(push )
18866#pragma warning(disable : 4127)
18873#ifdef JSON_HEDLEY_MSVC_VERSION
18874#pragma warning( pop )
18879 static_cast<void>(j);
18880 static_cast<void>(old_capacity);
18892 using parse_event_t = detail::parse_event_t;
18912 assert_invariant();
18920 assert_invariant();
18925 template <
typename CompatibleType,
18930 JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
18931 std::forward<CompatibleType>(
val))))
18933 JSONSerializer<U>::to_json(*
this, std::forward<CompatibleType>(
val));
18935 assert_invariant();
18940 template <
typename BasicJsonType,
18945 using other_boolean_t =
typename BasicJsonType::boolean_t;
18946 using other_number_float_t =
typename BasicJsonType::number_float_t;
18947 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
18948 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
18949 using other_string_t =
typename BasicJsonType::string_t;
18950 using other_object_t =
typename BasicJsonType::object_t;
18951 using other_array_t =
typename BasicJsonType::array_t;
18952 using other_binary_t =
typename BasicJsonType::binary_t;
18954 switch (
val.type())
18956 case value_t::boolean:
18959 case value_t::number_float:
18962 case value_t::number_integer:
18965 case value_t::number_unsigned:
18968 case value_t::string:
18969 JSONSerializer<other_string_t>::to_json(*
this,
val.template get_ref<const other_string_t&>());
18971 case value_t::object:
18972 JSONSerializer<other_object_t>::to_json(*
this,
val.template get_ref<const other_object_t&>());
18974 case value_t::array:
18975 JSONSerializer<other_array_t>::to_json(*
this,
val.template get_ref<const other_array_t&>());
18977 case value_t::binary:
18978 JSONSerializer<other_binary_t>::to_json(*
this,
val.template get_ref<const other_binary_t&>());
18980 case value_t::null:
18983 case value_t::discarded:
18984 m_type = value_t::discarded;
18990 assert_invariant();
18996 bool type_deduction =
true,
18997 value_t manual_type = value_t::array)
19001 bool is_an_object =
std::all_of(init.begin(), init.end(),
19004 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
19008 if (!type_deduction)
19011 if (manual_type == value_t::array)
19013 is_an_object =
false;
19026 m_type = value_t::object;
19029 for (
auto& element_ref : init)
19033 std::move(*((*element.m_value.array)[0].m_value.string)),
19034 std::move((*element.m_value.array)[1]));
19040 m_type = value_t::array;
19041 m_value.array = create<array_t>(init.begin(), init.end());
19045 assert_invariant();
19054 res.m_type = value_t::binary;
19055 res.m_value = init;
19065 res.m_type = value_t::binary;
19076 res.m_type = value_t::binary;
19087 res.m_type = value_t::binary;
19097 return basic_json(init,
false, value_t::array);
19105 return basic_json(init,
false, value_t::object);
19115 assert_invariant();
19120 template <
class InputIT,
typename std::enable_if <
19121 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
19122 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >
::type = 0 >
19135 m_type =
first.m_object->m_type;
19140 case value_t::boolean:
19141 case value_t::number_float:
19142 case value_t::number_integer:
19143 case value_t::number_unsigned:
19144 case value_t::string:
19147 || !last.m_it.primitive_iterator.is_end()))
19154 case value_t::null:
19155 case value_t::object:
19156 case value_t::array:
19157 case value_t::binary:
19158 case value_t::discarded:
19165 case value_t::number_integer:
19167 m_value.number_integer =
first.m_object->m_value.number_integer;
19171 case value_t::number_unsigned:
19173 m_value.number_unsigned =
first.m_object->m_value.number_unsigned;
19177 case value_t::number_float:
19179 m_value.number_float =
first.m_object->m_value.number_float;
19183 case value_t::boolean:
19189 case value_t::string:
19195 case value_t::object:
19197 m_value.object = create<object_t>(
first.m_it.object_iterator,
19198 last.m_it.object_iterator);
19202 case value_t::array:
19204 m_value.array = create<array_t>(
first.m_it.array_iterator,
19205 last.m_it.array_iterator);
19209 case value_t::binary:
19215 case value_t::null:
19216 case value_t::discarded:
19222 assert_invariant();
19230 template<
typename JsonRef,
19232 std::is_same<typename JsonRef::value_type, basic_json>>
::value,
int> = 0 >
19238 : m_type(other.m_type)
19241 other.assert_invariant();
19245 case value_t::object:
19251 case value_t::array:
19257 case value_t::string:
19263 case value_t::boolean:
19269 case value_t::number_integer:
19275 case value_t::number_unsigned:
19281 case value_t::number_float:
19287 case value_t::binary:
19293 case value_t::null:
19294 case value_t::discarded:
19300 assert_invariant();
19310 other.assert_invariant(
false);
19313 other.m_type = value_t::null;
19314 other.m_value = {};
19317 assert_invariant();
19323 std::is_nothrow_move_constructible<value_t>::value&&
19324 std::is_nothrow_move_assignable<value_t>::value&&
19325 std::is_nothrow_move_constructible<json_value>::value&&
19326 std::is_nothrow_move_assignable<json_value>::value
19330 other.assert_invariant();
19333 swap(m_type, other.m_type);
19337 assert_invariant();
19345 assert_invariant(
false);
19363 const char indent_char =
' ',
19364 const bool ensure_ascii =
false,
19368 serializer s(detail::output_adapter<char, string_t>(
result), indent_char, error_handler);
19372 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
19376 s.dump(*
this,
false, ensure_ascii, 0);
19407 return m_type == value_t::null;
19414 return m_type == value_t::boolean;
19428 return m_type == value_t::number_integer || m_type == value_t::number_unsigned;
19435 return m_type == value_t::number_unsigned;
19442 return m_type == value_t::number_float;
19449 return m_type == value_t::object;
19456 return m_type == value_t::array;
19463 return m_type == value_t::string;
19470 return m_type == value_t::binary;
19477 return m_type == value_t::discarded;
19524 constexpr const array_t* get_impl_ptr(
const array_t* )
const noexcept
19612 template<
typename ReferenceType,
typename ThisType>
19613 static ReferenceType get_ref_impl(ThisType& obj)
19616 auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
19633 template<
typename PointerType,
typename std::enable_if<
19634 std::is_pointer<PointerType>::value,
int>
::type = 0>
19635 auto get_ptr() noexcept -> decltype(
std::declval<basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
19638 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
19643 template <
typename PointerType,
typename std::enable_if <
19644 std::is_pointer<PointerType>::value&&
19645 std::is_const<typename std::remove_pointer<PointerType>::type>
::value,
int >
::type = 0 >
19646 constexpr auto get_ptr() const noexcept -> decltype(
std::declval<const basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
19649 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
19691 template <
typename ValueType,
19697 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
19699 auto ret = ValueType();
19700 JSONSerializer<ValueType>::from_json(*
this, ret);
19734 template <
typename ValueType,
19736 detail::has_non_default_from_json<basic_json_t, ValueType>::value,
19738 ValueType get_impl(detail::priority_tag<1> )
const noexcept(
noexcept(
19739 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
19741 return JSONSerializer<ValueType>::from_json(*
this);
19759 template <
typename BasicJsonType,
19761 detail::is_basic_json<BasicJsonType>::value,
19763 BasicJsonType get_impl(detail::priority_tag<2> )
const
19782 template<
typename BasicJsonType,
19784 std::is_same<BasicJsonType, basic_json_t>::value,
19786 basic_json get_impl(detail::priority_tag<3> )
const
19795 template<
typename PointerType,
19797 std::is_pointer<PointerType>::value,
19799 constexpr auto get_impl(detail::priority_tag<4> )
const noexcept
19800 ->
decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
19803 return get_ptr<PointerType>();
19830 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
19831#if defined(JSON_HAS_CPP_14)
19835 noexcept(
std::declval<const basic_json_t&>().template get_impl<ValueType>(detail::priority_tag<4> {})))
19841 static_assert(!std::is_reference<ValueTypeCV>::value,
19842 "get() cannot be used with reference types, you might want to use get_ref()");
19843 return get_impl<ValueType>(detail::priority_tag<4> {});
19873 template<
typename PointerType,
typename std::enable_if<
19874 std::is_pointer<PointerType>::value,
int>
::type = 0>
19875 auto get() noexcept -> decltype(
std::declval<basic_json_t&>().template
get_ptr<PointerType>())
19878 return get_ptr<PointerType>();
19883 template <
typename ValueType,
19888 ValueType &
get_to(ValueType&
v)
const noexcept(
noexcept(
19889 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(),
v)))
19891 JSONSerializer<ValueType>::from_json(*
this,
v);
19897 template<
typename ValueType,
19908 typename T, std::size_t N,
19909 typename Array = T (&)[N],
19913 noexcept(
noexcept(JSONSerializer<Array>::from_json(
19914 std::declval<const basic_json_t&>(),
v)))
19916 JSONSerializer<Array>::from_json(*
this,
v);
19922 template<
typename ReferenceType,
typename std::enable_if<
19923 std::is_reference<ReferenceType>::value,
int>
::type = 0>
19927 return get_ref_impl<ReferenceType>(*
this);
19932 template <
typename ReferenceType,
typename std::enable_if <
19933 std::is_reference<ReferenceType>::value&&
19934 std::is_const<typename std::remove_reference<ReferenceType>::type>
::value,
int >
::type = 0 >
19938 return get_ref_impl<ReferenceType>(*
this);
19970 template <
typename ValueType,
typename std::enable_if <
19979#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
19982#if defined(JSON_HAS_CPP_17)
20002 return *get_ptr<binary_t*>();
20014 return *get_ptr<const binary_t*>();
20037 return set_parent(
m_value.array->at(idx));
20060 return m_value.array->at(idx);
20084 auto it =
m_value.object->find(key);
20085 if (it ==
m_value.object->end())
20089 return set_parent(it->second);
20104 auto it =
m_value.object->find(std::forward<KeyType>(key));
20105 if (it ==
m_value.object->end())
20109 return set_parent(it->second);
20122 auto it =
m_value.object->find(key);
20123 if (it ==
m_value.object->end())
20142 auto it =
m_value.object->find(std::forward<KeyType>(key));
20143 if (it ==
m_value.object->end())
20157 m_type = value_t::array;
20158 m_value.array = create<array_t>();
20159 assert_invariant();
20166 if (idx >=
m_value.array->size())
20168#if JSON_DIAGNOSTICS
20170 const auto old_size =
m_value.array->size();
20171 const auto old_capacity =
m_value.array->capacity();
20173 m_value.array->resize(idx + 1);
20175#if JSON_DIAGNOSTICS
20187 assert_invariant();
20190 return m_value.array->operator[](idx);
20203 return m_value.array->operator[](idx);
20216 m_type = value_t::object;
20218 assert_invariant();
20225 return set_parent(
result.first->second);
20248 template<
typename T>
20251 return operator[](
typename object_t::key_type(key));
20254 template<
typename T>
20257 return operator[](
typename object_t::key_type(key));
20269 m_type = value_t::object;
20271 assert_invariant();
20277 auto result =
m_value.object->emplace(std::forward<KeyType>(key),
nullptr);
20278 return set_parent(
result.first->second);
20305 std::is_same<KeyType, typename object_t::key_type>::value
20307 && !std::is_same<value_t, ValueType>::value,
int > = 0 >
20308 typename std::decay<ValueType>::type
value(
const KeyType& key, ValueType && default_value)
const
20314 const auto it =
find(key);
20320 return std::forward<ValueType>(default_value);
20329 string_t value(
const typename object_t::key_type& key,
const char* default_value)
const
20339 && !std::is_same<value_t, ValueType>::value,
int > = 0 >
20340 typename std::decay<ValueType>::type
value(
const char* key, ValueType && default_value)
const
20342 return value(
typename object_t::key_type(key), std::forward<ValueType>(default_value));
20347 return value(
typename object_t::key_type(key),
string_t(default_value));
20355 && !std::is_same<value_t, ValueType>::value
20357 typename std::decay<ValueType>::type
value(KeyType && key, ValueType && default_value)
const
20363 const auto it =
find(std::forward<KeyType>(key));
20369 return std::forward<ValueType>(default_value);
20382 return value(std::forward<KeyType>(key),
string_t(default_value));
20401 return default_value;
20413 return value(ptr.convert(), default_value);
20425 template<
typename BasicJsonType>
20430 return value(ptr.convert(), default_value);
20468 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
20469 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
20482 case value_t::boolean:
20483 case value_t::number_float:
20484 case value_t::number_integer:
20485 case value_t::number_unsigned:
20486 case value_t::string:
20487 case value_t::binary:
20496 AllocatorType<string_t> alloc;
20497 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.string);
20498 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.string, 1);
20503 AllocatorType<binary_t> alloc;
20504 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.binary);
20505 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.binary, 1);
20509 m_type = value_t::null;
20510 assert_invariant();
20514 case value_t::object:
20516 result.m_it.object_iterator =
m_value.object->erase(pos.m_it.object_iterator);
20520 case value_t::array:
20522 result.m_it.array_iterator =
m_value.array->erase(pos.m_it.array_iterator);
20526 case value_t::null:
20527 case value_t::discarded:
20538 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
20539 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
20552 case value_t::boolean:
20553 case value_t::number_float:
20554 case value_t::number_integer:
20555 case value_t::number_unsigned:
20556 case value_t::string:
20557 case value_t::binary:
20560 || !last.m_it.primitive_iterator.is_end()))
20567 AllocatorType<string_t> alloc;
20568 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.string);
20569 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.string, 1);
20574 AllocatorType<binary_t> alloc;
20575 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_value.binary);
20576 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.binary, 1);
20580 m_type = value_t::null;
20581 assert_invariant();
20585 case value_t::object:
20588 last.m_it.object_iterator);
20592 case value_t::array:
20595 last.m_it.array_iterator);
20599 case value_t::null:
20600 case value_t::discarded:
20611 size_type erase_internal(KeyType && key)
20619 return m_value.object->erase(std::forward<KeyType>(key));
20623 !detail::has_erase_with_key_type<basic_json_t, KeyType>::value,
int > = 0 >
20624 size_type erase_internal(KeyType && key)
20632 const auto it =
m_value.object->find(std::forward<KeyType>(key));
20633 if (it !=
m_value.object->end())
20649 return erase_internal(key);
20658 return erase_internal(std::forward<KeyType>(key));
20729 result.m_it.object_iterator =
m_value.object->find(std::forward<KeyType>(key));
20745 result.m_it.object_iterator =
m_value.object->find(std::forward<KeyType>(key));
20766 return is_object() ?
m_value.object->count(std::forward<KeyType>(key)) : 0;
20771 bool contains(
const typename object_t::key_type& key)
const
20789 return ptr.contains(
this);
20792 template<
typename BasicJsonType>
20796 return ptr.contains(
this);
20910 return ref.items();
20921 return ref.items();
20928 return iteration_proxy<iterator>(*
this);
20933 iteration_proxy<const_iterator>
items() const noexcept
20935 return iteration_proxy<const_iterator>(*
this);
20954 case value_t::null:
20960 case value_t::array:
20963 return m_value.array->empty();
20966 case value_t::object:
20969 return m_value.object->empty();
20972 case value_t::string:
20973 case value_t::boolean:
20974 case value_t::number_integer:
20975 case value_t::number_unsigned:
20976 case value_t::number_float:
20977 case value_t::binary:
20978 case value_t::discarded:
20993 case value_t::null:
20999 case value_t::array:
21002 return m_value.array->size();
21005 case value_t::object:
21008 return m_value.object->size();
21011 case value_t::string:
21012 case value_t::boolean:
21013 case value_t::number_integer:
21014 case value_t::number_unsigned:
21015 case value_t::number_float:
21016 case value_t::binary:
21017 case value_t::discarded:
21032 case value_t::array:
21035 return m_value.array->max_size();
21038 case value_t::object:
21041 return m_value.object->max_size();
21044 case value_t::null:
21045 case value_t::string:
21046 case value_t::boolean:
21047 case value_t::number_integer:
21048 case value_t::number_unsigned:
21049 case value_t::number_float:
21050 case value_t::binary:
21051 case value_t::discarded:
21076 case value_t::number_integer:
21082 case value_t::number_unsigned:
21088 case value_t::number_float:
21094 case value_t::boolean:
21100 case value_t::string:
21106 case value_t::binary:
21112 case value_t::array:
21118 case value_t::object:
21124 case value_t::null:
21125 case value_t::discarded:
21144 m_type = value_t::array;
21146 assert_invariant();
21150 const auto old_capacity =
m_value.array->capacity();
21152 set_parent(
m_value.array->back(), old_capacity);
21177 m_type = value_t::array;
21179 assert_invariant();
21183 const auto old_capacity =
m_value.array->capacity();
21185 set_parent(
m_value.array->back(), old_capacity);
21209 m_type = value_t::object;
21211 assert_invariant();
21216 set_parent(
res.first->second);
21231 if (
is_object() && init.size() == 2 && (*init.begin())->is_string())
21233 basic_json&& key = init.begin()->moved_or_copied();
21234 push_back(
typename object_t::value_type(
21253 template<
class... Args>
21265 m_type = value_t::array;
21267 assert_invariant();
21271 const auto old_capacity =
m_value.array->capacity();
21272 m_value.array->emplace_back(std::forward<Args>(args)...);
21273 return set_parent(
m_value.array->back(), old_capacity);
21278 template<
class... Args>
21290 m_type = value_t::object;
21292 assert_invariant();
21296 auto res =
m_value.object->emplace(std::forward<Args>(args)...);
21297 set_parent(
res.first->second);
21301 it.m_it.object_iterator =
res.first;
21304 return {it,
res.second};
21310 template<
typename... Args>
21318 result.m_it.array_iterator =
m_value.array->begin() + insert_pos;
21465 m_type = value_t::object;
21466 m_value.object = create<object_t>();
21467 assert_invariant();
21487 for (
auto it =
first; it != last; ++it)
21489 if (merge_objects && it.value().is_object())
21491 auto it2 =
m_value.object->find(it.key());
21492 if (it2 !=
m_value.object->end())
21494 it2->second.update(it.value(),
true);
21498 m_value.object->operator[](it.key()) = it.value();
21499#if JSON_DIAGNOSTICS
21500 m_value.object->operator[](it.key()).m_parent =
this;
21508 std::is_nothrow_move_constructible<value_t>::value&&
21509 std::is_nothrow_move_assignable<value_t>::value&&
21510 std::is_nothrow_move_constructible<json_value>::value&&
21511 std::is_nothrow_move_assignable<json_value>::value
21518 other.set_parents();
21519 assert_invariant();
21525 std::is_nothrow_move_constructible<value_t>::value&&
21526 std::is_nothrow_move_assignable<value_t>::value&&
21527 std::is_nothrow_move_constructible<json_value>::value&&
21528 std::is_nothrow_move_assignable<json_value>::value
21624#pragma GCC diagnostic push
21625#pragma GCC diagnostic ignored "-Wfloat-equal"
21627 const auto lhs_type = lhs.type();
21628 const auto rhs_type = rhs.type();
21630 if (lhs_type == rhs_type)
21634 case value_t::array:
21635 return *lhs.m_value.array == *rhs.m_value.array;
21637 case value_t::object:
21638 return *lhs.m_value.object == *rhs.m_value.object;
21640 case value_t::null:
21643 case value_t::string:
21644 return *lhs.m_value.string == *rhs.m_value.string;
21646 case value_t::boolean:
21647 return lhs.m_value.boolean == rhs.m_value.boolean;
21649 case value_t::number_integer:
21650 return lhs.m_value.number_integer == rhs.m_value.number_integer;
21652 case value_t::number_unsigned:
21653 return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
21655 case value_t::number_float:
21656 return lhs.m_value.number_float == rhs.m_value.number_float;
21658 case value_t::binary:
21659 return *lhs.m_value.binary == *rhs.m_value.binary;
21661 case value_t::discarded:
21666 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float)
21668 return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
21670 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer)
21672 return lhs.m_value.number_float ==
static_cast<number_float_t>(rhs.m_value.number_integer);
21674 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float)
21676 return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
21678 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned)
21680 return lhs.m_value.number_float ==
static_cast<number_float_t>(rhs.m_value.number_unsigned);
21682 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer)
21684 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
21686 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned)
21688 return lhs.m_value.number_integer ==
static_cast<number_integer_t>(rhs.m_value.number_unsigned);
21693#pragma GCC diagnostic pop
21699 template<
typename ScalarType,
typename std::enable_if<
21700 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21708 template<
typename ScalarType,
typename std::enable_if<
21709 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21719 return !(lhs == rhs);
21724 template<
typename ScalarType,
typename std::enable_if<
21725 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21733 template<
typename ScalarType,
typename std::enable_if<
21734 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21744 const auto lhs_type = lhs.type();
21745 const auto rhs_type = rhs.type();
21747 if (lhs_type == rhs_type)
21751 case value_t::array:
21754 return (*lhs.m_value.array) < (*rhs.m_value.array);
21756 case value_t::object:
21757 return (*lhs.m_value.object) < (*rhs.m_value.object);
21759 case value_t::null:
21762 case value_t::string:
21763 return (*lhs.m_value.string) < (*rhs.m_value.string);
21765 case value_t::boolean:
21766 return (lhs.m_value.boolean) < (rhs.m_value.boolean);
21768 case value_t::number_integer:
21769 return (lhs.m_value.number_integer) < (rhs.m_value.number_integer);
21771 case value_t::number_unsigned:
21772 return (lhs.m_value.number_unsigned) < (rhs.m_value.number_unsigned);
21774 case value_t::number_float:
21775 return (lhs.m_value.number_float) < (rhs.m_value.number_float);
21777 case value_t::binary:
21778 return (*lhs.m_value.binary) < (*rhs.m_value.binary);
21780 case value_t::discarded:
21785 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float)
21787 return static_cast<number_float_t>(lhs.m_value.number_integer) < rhs.m_value.number_float;
21789 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer)
21791 return lhs.m_value.number_float <
static_cast<number_float_t>(rhs.m_value.number_integer);
21793 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float)
21795 return static_cast<number_float_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_float;
21797 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned)
21799 return lhs.m_value.number_float <
static_cast<number_float_t>(rhs.m_value.number_unsigned);
21801 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned)
21803 return lhs.m_value.number_integer <
static_cast<number_integer_t>(rhs.m_value.number_unsigned);
21805 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer)
21807 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_integer;
21818 template<
typename ScalarType,
typename std::enable_if<
21819 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21827 template<
typename ScalarType,
typename std::enable_if<
21828 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21838 return !(rhs < lhs);
21843 template<
typename ScalarType,
typename std::enable_if<
21844 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21852 template<
typename ScalarType,
typename std::enable_if<
21853 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21863 return !(lhs <= rhs);
21868 template<
typename ScalarType,
typename std::enable_if<
21869 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21877 template<
typename ScalarType,
typename std::enable_if<
21878 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21888 return !(lhs < rhs);
21893 template<
typename ScalarType,
typename std::enable_if<
21894 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21902 template<
typename ScalarType,
typename std::enable_if<
21903 std::is_scalar<ScalarType>::value,
int>
::type = 0>
21923 const bool pretty_print = o.width() > 0;
21924 const auto indentation = pretty_print ? o.width() : 0;
21930 serializer s(detail::output_adapter<char>(o), o.fill());
21931 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(
indentation));
21959 template<
typename InputType>
21963 const bool allow_exceptions =
true,
21964 const bool ignore_comments =
false)
21967 parser(detail::input_adapter(std::forward<InputType>(i)), cb, allow_exceptions, ignore_comments).
parse(
true,
result);
21973 template<
typename IteratorType>
21978 const bool allow_exceptions =
true,
21979 const bool ignore_comments =
false)
21990 const
bool allow_exceptions =
true,
21991 const
bool ignore_comments =
false)
22000 template<
typename InputType>
22002 const bool ignore_comments =
false)
22004 return parser(detail::input_adapter(std::forward<InputType>(i)),
nullptr,
false, ignore_comments).accept(
true);
22009 template<
typename IteratorType>
22011 const bool ignore_comments =
false)
22018 static
bool accept(detail::span_input_adapter&& i,
22019 const
bool ignore_comments =
false)
22021 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
22026 template <
typename InputType,
typename SAX>
22029 input_format_t
format = input_format_t::
json,
22030 const
bool strict =
true,
22031 const
bool ignore_comments =
false)
22033 auto ia = detail::input_adapter(std::forward<InputType>(i));
22034 return format == input_format_t::json
22035 ?
parser(
std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
22041 template<
class IteratorType,
class SAX>
22044 input_format_t
format = input_format_t::
json,
22045 const
bool strict =
true,
22046 const
bool ignore_comments =
false)
22049 return format == input_format_t::json
22050 ?
parser(
std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
22059 template <
typename SAX>
22063 input_format_t
format = input_format_t::
json,
22064 const
bool strict =
true,
22065 const
bool ignore_comments =
false)
22068 return format == input_format_t::json
22070 ?
parser(
std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
22091 parser(detail::input_adapter(i)).parse(
false, j);
22108 case value_t::null:
22110 case value_t::object:
22112 case value_t::array:
22114 case value_t::string:
22116 case value_t::boolean:
22118 case value_t::binary:
22120 case value_t::discarded:
22121 return "discarded";
22122 case value_t::number_integer:
22123 case value_t::number_unsigned:
22124 case value_t::number_float:
22137 value_t m_type = value_t::null;
22142#if JSON_DIAGNOSTICS
22159 std::vector<std::uint8_t>
result;
22168 binary_writer<std::uint8_t>(o).write_cbor(j);
22175 binary_writer<char>(o).write_cbor(j);
22182 std::vector<std::uint8_t>
result;
22191 binary_writer<std::uint8_t>(o).write_msgpack(j);
22198 binary_writer<char>(o).write_msgpack(j);
22204 const bool use_size =
false,
22205 const bool use_type =
false)
22207 std::vector<std::uint8_t>
result;
22215 const bool use_size =
false,
const bool use_type =
false)
22217 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type);
22223 const bool use_size =
false,
const bool use_type =
false)
22225 binary_writer<char>(o).write_ubjson(j, use_size, use_type);
22231 const bool use_size =
false,
22232 const bool use_type =
false)
22234 std::vector<std::uint8_t>
result;
22242 const bool use_size =
false,
const bool use_type =
false)
22244 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type,
true,
true);
22250 const bool use_size =
false,
const bool use_type =
false)
22252 binary_writer<char>(o).write_ubjson(j, use_size, use_type,
true,
true);
22259 std::vector<std::uint8_t>
result;
22268 binary_writer<std::uint8_t>(o).write_bson(j);
22275 binary_writer<char>(o).write_bson(j);
22280 template<
typename InputType>
22283 const bool strict =
true,
22284 const bool allow_exceptions =
true,
22289 auto ia = detail::input_adapter(std::forward<InputType>(i));
22296 template<
typename IteratorType>
22299 const bool strict =
true,
22300 const bool allow_exceptions =
true,
22310 template<
typename T>
22314 const
bool strict =
true,
22315 const
bool allow_exceptions =
true,
22318 return from_cbor(ptr, ptr +
len, strict, allow_exceptions, tag_handler);
22325 const
bool strict =
true,
22326 const
bool allow_exceptions =
true,
22339 template<
typename InputType>
22342 const bool strict =
true,
22343 const bool allow_exceptions =
true)
22347 auto ia = detail::input_adapter(std::forward<InputType>(i));
22354 template<
typename IteratorType>
22357 const bool strict =
true,
22358 const bool allow_exceptions =
true)
22367 template<
typename T>
22371 const
bool strict =
true,
22372 const
bool allow_exceptions =
true)
22380 const
bool strict =
true,
22381 const
bool allow_exceptions =
true)
22393 template<
typename InputType>
22396 const bool strict =
true,
22397 const bool allow_exceptions =
true)
22401 auto ia = detail::input_adapter(std::forward<InputType>(i));
22408 template<
typename IteratorType>
22411 const bool strict =
true,
22412 const bool allow_exceptions =
true)
22421 template<
typename T>
22425 const
bool strict =
true,
22426 const
bool allow_exceptions =
true)
22434 const
bool strict =
true,
22435 const
bool allow_exceptions =
true)
22448 template<
typename InputType>
22451 const bool strict =
true,
22452 const bool allow_exceptions =
true)
22456 auto ia = detail::input_adapter(std::forward<InputType>(i));
22463 template<
typename IteratorType>
22466 const bool strict =
true,
22467 const bool allow_exceptions =
true)
22476 template<
typename T>
22479 const bool strict =
true,
22480 const bool allow_exceptions =
true)
22487 const bool strict =
true,
22488 const bool allow_exceptions =
true)
22501 template<
typename InputType>
22504 const bool strict =
true,
22505 const bool allow_exceptions =
true)
22509 auto ia = detail::input_adapter(std::forward<InputType>(i));
22516 template<
typename IteratorType>
22519 const bool strict =
true,
22520 const bool allow_exceptions =
true)
22529 template<
typename T>
22533 const
bool strict =
true,
22534 const
bool allow_exceptions =
true)
22536 return from_bson(ptr, ptr +
len, strict, allow_exceptions);
22542 const
bool strict =
true,
22543 const
bool allow_exceptions =
true)
22565 return ptr.get_unchecked(
this);
22568 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
22572 return ptr.get_unchecked(
this);
22579 return ptr.get_unchecked(
this);
22582 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
22586 return ptr.get_unchecked(
this);
22593 return ptr.get_checked(
this);
22596 template<
typename BasicJsonType>
22600 return ptr.get_checked(
this);
22607 return ptr.get_checked(
this);
22610 template<
typename BasicJsonType>
22614 return ptr.get_checked(
this);
22622 json_pointer::flatten(
"", *
this,
result);
22630 return json_pointer::unflatten(*
this);
22650 enum class patch_operations {
add, remove, replace, move, copy, test, invalid};
22652 const auto get_op = [](
const std::string & op)
22656 return patch_operations::add;
22658 if (op ==
"remove")
22660 return patch_operations::remove;
22662 if (op ==
"replace")
22664 return patch_operations::replace;
22668 return patch_operations::move;
22672 return patch_operations::copy;
22676 return patch_operations::test;
22679 return patch_operations::invalid;
22694 if (top_pointer != ptr)
22700 const auto last_path = ptr.
back();
22704 switch (parent.m_type)
22706 case value_t::null:
22707 case value_t::object:
22710 parent[last_path] =
val;
22714 case value_t::array:
22716 if (last_path ==
"-")
22723 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
22737 case value_t::string:
22738 case value_t::boolean:
22739 case value_t::number_integer:
22740 case value_t::number_unsigned:
22741 case value_t::number_float:
22742 case value_t::binary:
22743 case value_t::discarded:
22753 const auto last_path = ptr.
back();
22761 auto it = parent.
find(last_path);
22774 parent.
erase(json_pointer::template array_index<basic_json_t>(last_path));
22785 for (
const auto&
val : json_patch)
22788 const auto get_value = [&
val](
const std::string & op,
22789 const std::string & member,
22796 const auto error_msg = (op ==
"op") ?
"operation" :
detail::concat(
"operation '", op,
'\'');
22827 switch (get_op(op))
22829 case patch_operations::add:
22831 operation_add(ptr, get_value(
"add",
"value",
false));
22835 case patch_operations::remove:
22837 operation_remove(ptr);
22841 case patch_operations::replace:
22844 result.at(ptr) = get_value(
"replace",
"value",
false);
22848 case patch_operations::move:
22850 const auto from_path = get_value(
"move",
"from",
true).template
get<std::string>();
22860 operation_remove(from_ptr);
22861 operation_add(ptr,
v);
22865 case patch_operations::copy:
22867 const auto from_path = get_value(
"copy",
"from",
true).template
get<std::string>();
22876 operation_add(ptr,
v);
22880 case patch_operations::test:
22882 bool success =
false;
22887 success = (
result.at(ptr) == get_value(
"test",
"value",
false));
22903 case patch_operations::invalid:
22920 const std::string&
path =
"")
22936 {
"op",
"replace"}, {
"path",
path}, {
"value",
target}
22943 case value_t::array:
22951 result.insert(
result.end(), temp_diff.begin(), temp_diff.end());
22960 while (i <
source.size())
22973 while (i <
target.size())
22987 case value_t::object:
22990 for (
auto it =
source.cbegin(); it !=
source.cend(); ++it)
22998 auto temp_diff =
diff(it.value(),
target[it.key()], path_key);
22999 result.insert(
result.end(), temp_diff.begin(), temp_diff.end());
23004 result.push_back(
object(
23006 {
"op",
"remove"}, {
"path", path_key}
23012 for (
auto it =
target.cbegin(); it !=
target.cend(); ++it)
23020 {
"op",
"add"}, {
"path", path_key},
23021 {
"value", it.value()}
23029 case value_t::null:
23030 case value_t::string:
23031 case value_t::boolean:
23032 case value_t::number_integer:
23033 case value_t::number_unsigned:
23034 case value_t::number_float:
23035 case value_t::binary:
23036 case value_t::discarded:
23042 {
"op",
"replace"}, {
"path",
path}, {
"value",
target}
23070 for (
auto it = apply_patch.
begin(); it != apply_patch.
end(); ++it)
23072 if (it.value().is_null())
23084 *
this = apply_patch;
23113 std::size_t
operator()(
const nlohmann::NLOHMANN_BASIC_JSON_TPL& j)
const
23115 return nlohmann::detail::hash(j);
23135#ifndef JSON_HAS_CPP_20
23140inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2)
noexcept(
23141 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&&
23142 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
23162inline
nlohmann::json::json_pointer operator "" _json_pointer(const
char* s,
std::
size_t n)
23171#if defined(__clang__)
23172 #pragma clang diagnostic pop
23177#undef JSON_INTERNAL_CATCH
23179#undef JSON_PRIVATE_UNLESS_TESTED
23180#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
23181#undef NLOHMANN_BASIC_JSON_TPL
23182#undef JSON_EXPLICIT
23183#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
23184#undef JSON_NO_UNIQUE_ADDRESS
23186#ifndef JSON_TEST_KEEP_MACROS
23189 #undef JSON_HAS_CPP_11
23190 #undef JSON_HAS_CPP_14
23191 #undef JSON_HAS_CPP_17
23192 #undef JSON_HAS_CPP_20
23193 #undef JSON_HAS_FILESYSTEM
23194 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
23195 #undef JSON_HAS_THREE_WAY_COMPARISON
23201#undef JSON_HEDLEY_ALWAYS_INLINE
23202#undef JSON_HEDLEY_ARM_VERSION
23203#undef JSON_HEDLEY_ARM_VERSION_CHECK
23204#undef JSON_HEDLEY_ARRAY_PARAM
23205#undef JSON_HEDLEY_ASSUME
23206#undef JSON_HEDLEY_BEGIN_C_DECLS
23207#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
23208#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
23209#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
23210#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
23211#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
23212#undef JSON_HEDLEY_CLANG_HAS_FEATURE
23213#undef JSON_HEDLEY_CLANG_HAS_WARNING
23214#undef JSON_HEDLEY_COMPCERT_VERSION
23215#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
23216#undef JSON_HEDLEY_CONCAT
23217#undef JSON_HEDLEY_CONCAT3
23218#undef JSON_HEDLEY_CONCAT3_EX
23219#undef JSON_HEDLEY_CONCAT_EX
23220#undef JSON_HEDLEY_CONST
23221#undef JSON_HEDLEY_CONSTEXPR
23222#undef JSON_HEDLEY_CONST_CAST
23223#undef JSON_HEDLEY_CPP_CAST
23224#undef JSON_HEDLEY_CRAY_VERSION
23225#undef JSON_HEDLEY_CRAY_VERSION_CHECK
23226#undef JSON_HEDLEY_C_DECL
23227#undef JSON_HEDLEY_DEPRECATED
23228#undef JSON_HEDLEY_DEPRECATED_FOR
23229#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
23230#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
23231#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
23232#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
23233#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
23234#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
23235#undef JSON_HEDLEY_DIAGNOSTIC_POP
23236#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
23237#undef JSON_HEDLEY_DMC_VERSION
23238#undef JSON_HEDLEY_DMC_VERSION_CHECK
23239#undef JSON_HEDLEY_EMPTY_BASES
23240#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
23241#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
23242#undef JSON_HEDLEY_END_C_DECLS
23243#undef JSON_HEDLEY_FLAGS
23244#undef JSON_HEDLEY_FLAGS_CAST
23245#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
23246#undef JSON_HEDLEY_GCC_HAS_BUILTIN
23247#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
23248#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
23249#undef JSON_HEDLEY_GCC_HAS_EXTENSION
23250#undef JSON_HEDLEY_GCC_HAS_FEATURE
23251#undef JSON_HEDLEY_GCC_HAS_WARNING
23252#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
23253#undef JSON_HEDLEY_GCC_VERSION
23254#undef JSON_HEDLEY_GCC_VERSION_CHECK
23255#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
23256#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
23257#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
23258#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
23259#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
23260#undef JSON_HEDLEY_GNUC_HAS_FEATURE
23261#undef JSON_HEDLEY_GNUC_HAS_WARNING
23262#undef JSON_HEDLEY_GNUC_VERSION
23263#undef JSON_HEDLEY_GNUC_VERSION_CHECK
23264#undef JSON_HEDLEY_HAS_ATTRIBUTE
23265#undef JSON_HEDLEY_HAS_BUILTIN
23266#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
23267#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
23268#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
23269#undef JSON_HEDLEY_HAS_EXTENSION
23270#undef JSON_HEDLEY_HAS_FEATURE
23271#undef JSON_HEDLEY_HAS_WARNING
23272#undef JSON_HEDLEY_IAR_VERSION
23273#undef JSON_HEDLEY_IAR_VERSION_CHECK
23274#undef JSON_HEDLEY_IBM_VERSION
23275#undef JSON_HEDLEY_IBM_VERSION_CHECK
23276#undef JSON_HEDLEY_IMPORT
23277#undef JSON_HEDLEY_INLINE
23278#undef JSON_HEDLEY_INTEL_CL_VERSION
23279#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
23280#undef JSON_HEDLEY_INTEL_VERSION
23281#undef JSON_HEDLEY_INTEL_VERSION_CHECK
23282#undef JSON_HEDLEY_IS_CONSTANT
23283#undef JSON_HEDLEY_IS_CONSTEXPR_
23284#undef JSON_HEDLEY_LIKELY
23285#undef JSON_HEDLEY_MALLOC
23286#undef JSON_HEDLEY_MCST_LCC_VERSION
23287#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
23288#undef JSON_HEDLEY_MESSAGE
23289#undef JSON_HEDLEY_MSVC_VERSION
23290#undef JSON_HEDLEY_MSVC_VERSION_CHECK
23291#undef JSON_HEDLEY_NEVER_INLINE
23292#undef JSON_HEDLEY_NON_NULL
23293#undef JSON_HEDLEY_NO_ESCAPE
23294#undef JSON_HEDLEY_NO_RETURN
23295#undef JSON_HEDLEY_NO_THROW
23296#undef JSON_HEDLEY_NULL
23297#undef JSON_HEDLEY_PELLES_VERSION
23298#undef JSON_HEDLEY_PELLES_VERSION_CHECK
23299#undef JSON_HEDLEY_PGI_VERSION
23300#undef JSON_HEDLEY_PGI_VERSION_CHECK
23301#undef JSON_HEDLEY_PREDICT
23302#undef JSON_HEDLEY_PRINTF_FORMAT
23303#undef JSON_HEDLEY_PRIVATE
23304#undef JSON_HEDLEY_PUBLIC
23305#undef JSON_HEDLEY_PURE
23306#undef JSON_HEDLEY_REINTERPRET_CAST
23307#undef JSON_HEDLEY_REQUIRE
23308#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
23309#undef JSON_HEDLEY_REQUIRE_MSG
23310#undef JSON_HEDLEY_RESTRICT
23311#undef JSON_HEDLEY_RETURNS_NON_NULL
23312#undef JSON_HEDLEY_SENTINEL
23313#undef JSON_HEDLEY_STATIC_ASSERT
23314#undef JSON_HEDLEY_STATIC_CAST
23315#undef JSON_HEDLEY_STRINGIFY
23316#undef JSON_HEDLEY_STRINGIFY_EX
23317#undef JSON_HEDLEY_SUNPRO_VERSION
23318#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
23319#undef JSON_HEDLEY_TINYC_VERSION
23320#undef JSON_HEDLEY_TINYC_VERSION_CHECK
23321#undef JSON_HEDLEY_TI_ARMCL_VERSION
23322#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
23323#undef JSON_HEDLEY_TI_CL2000_VERSION
23324#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
23325#undef JSON_HEDLEY_TI_CL430_VERSION
23326#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
23327#undef JSON_HEDLEY_TI_CL6X_VERSION
23328#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
23329#undef JSON_HEDLEY_TI_CL7X_VERSION
23330#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
23331#undef JSON_HEDLEY_TI_CLPRU_VERSION
23332#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
23333#undef JSON_HEDLEY_TI_VERSION
23334#undef JSON_HEDLEY_TI_VERSION_CHECK
23335#undef JSON_HEDLEY_UNAVAILABLE
23336#undef JSON_HEDLEY_UNLIKELY
23337#undef JSON_HEDLEY_UNPREDICTABLE
23338#undef JSON_HEDLEY_UNREACHABLE
23339#undef JSON_HEDLEY_UNREACHABLE_RETURN
23340#undef JSON_HEDLEY_VERSION
23341#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
23342#undef JSON_HEDLEY_VERSION_DECODE_MINOR
23343#undef JSON_HEDLEY_VERSION_DECODE_REVISION
23344#undef JSON_HEDLEY_VERSION_ENCODE
23345#undef JSON_HEDLEY_WARNING
23346#undef JSON_HEDLEY_WARN_UNUSED_RESULT
23347#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
23348#undef JSON_HEDLEY_FALL_THROUGH
type
Definition Gameobj.h:11
unsigned short uint16_t
Definition stdint.h:79
signed __int64 int64_t
Definition stdint.h:89
unsigned int uint32_t
Definition stdint.h:80
unsigned char uint8_t
Definition stdint.h:78
unsigned __int64 uint64_t
Definition stdint.h:90
#define C
Definition stb_vorbis.c:5132
result
Definition core_func_integer.cpp:18
#define u
Definition core_func_integer_find_lsb.cpp:179
genType add(genType const &a, genType const &b)
Definition core_setup_force_size_t_length.cpp:6
return(unsigned char) __builtin_ia32_ktestzsi(__A
#define or
Definition iso646.h:39
#define true
Definition stdbool.h:38
#define false
Definition stdbool.h:39
#define bool
Definition stdbool.h:33
__PTRDIFF_TYPE__ ptrdiff_t
Definition stddef.h:146
__SIZE_TYPE__ size_t
Definition stddef.h:215
#define exp(z)
Definition tgmath.h:73
EGLStreamKHR stream
Definition eglext.h:297
typedef void(EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC)(EGLDisplay dpy
EGLImageKHR EGLint * name
Definition eglext.h:636
EGLSurface EGLint EGLint y
Definition eglext.h:713
EGLContext EGLenum EGLClientBuffer buffer
Definition eglext.h:149
EGLSurface EGLint x
Definition eglext.h:713
EGLContext EGLenum target
Definition eglext.h:149
EGLSetBlobFuncANDROID EGLGetBlobFuncANDROID get
Definition eglext.h:375
GLclampf ref
Definition gl2ext.h:1918
GLint GLint GLint GLint GLint w
Definition gl2ext.h:1595
GLsizei size
Definition gl2ext.h:1935
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum format
Definition gl2ext.h:1121
GLint index
Definition gl2ext.h:1492
GLsizei GLsizei GLchar * source
Definition gl2ext.h:1333
GLenum GLuint GLenum GLsizei const GLchar * message
Definition gl2ext.h:186
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition gl2ext.h:1124
GLuint object
Definition gl2ext.h:1436
GLsizei GLsizei GLenum GLvoid * binary
Definition gl2ext.h:1059
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition gl2ext.h:1199
GLint first
Definition gl2ext.h:1298
GLintptr offset
Definition gl2ext.h:1470
GLfloat f
Definition glad.h:2901
const GLdouble * v
Definition glad.h:1495
GLuint res
Definition glad.h:3616
GLenum GLsizei len
Definition glad.h:2989
GLuint GLuint end
Definition glad.h:1185
GLsizei const GLchar ** string
Definition glad.h:1426
GLboolean GLboolean GLboolean b
Definition glad.h:1629
GLenum GLint * range
Definition glad.h:2898
GLuint GLfloat * val
Definition glad.h:1976
GLuint GLuint num
Definition glad.h:3631
GLboolean r
Definition glad.h:1629
GLuint start
Definition glad.h:1185
GLboolean GLboolean GLboolean GLboolean a
Definition glad.h:1629
GLenum void ** pointer
Definition glad.h:1414
unsigned char byte
Definition rlgl.h:192
bool
Definition raylib.h:192
#define is
Definition Monobehavior.h:46
A TOML array.
Definition array.h:265
TOML_NODISCARD iterator begin() noexcept
Returns an iterator to the first element.
Definition array.h:790
TOML_NODISCARD iterator end() noexcept
Returns an iterator to one-past-the-last element.
Definition array.h:811
TOML_NODISCARD size_t size() const noexcept
Returns the number of elements in the array.
Definition array.h:1073
a class to store JSON values
Definition json.hpp:18200
ValueType & get_to(ValueType &v) const
Definition json.hpp:19901
void insert(const_iterator first, const_iterator last)
inserts range of elements into object
Definition json.hpp:21428
detail::parser_callback_t< basic_json > parser_callback_t
per-element parser callback type
Definition json.hpp:18896
iteration_proxy< iterator > items() noexcept
helper to access iterator member functions in range-based for
Definition json.hpp:20926
const_reverse_iterator crbegin() const noexcept
returns a const reverse iterator to the last element
Definition json.hpp:20889
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(const T *ptr, std::size_t len, const bool strict=true, const bool allow_exceptions=true)
Definition json.hpp:22478
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
Definition json.hpp:22577
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
Definition json.hpp:22563
friend bool operator==(const_reference lhs, ScalarType rhs) noexcept
comparison: equal
Definition json.hpp:21701
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
Definition json.hpp:19440
const_reference operator[](T *key) const
Definition json.hpp:20255
NumberIntegerType number_integer_t
a type for a number (integer)
Definition json.hpp:18457
friend bool operator==(const_reference lhs, const_reference rhs) noexcept
comparison: equal
Definition json.hpp:21621
void update(const_reference j, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition json.hpp:21453
static bool sax_parse(InputType &&i, SAX *sax, input_format_t format=input_format_t::json, const bool strict=true, const bool ignore_comments=false)
generate SAX events
Definition json.hpp:22028
static std::vector< std::uint8_t > to_bjdata(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
Definition json.hpp:22230
::nlohmann::json_pointer< StringType > json_pointer
JSON Pointer, see nlohmann::json_pointer.
Definition json.hpp:18266
ReferenceType get_ref()
get a reference value (implicit)
Definition json.hpp:19924
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse(InputType &&i, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
deserialize from a compatible input
Definition json.hpp:21961
reference emplace_back(Args &&... args)
add an object to an array
Definition json.hpp:21254
json_sax< basic_json > json_sax_t
SAX interface type, see nlohmann::json_sax.
Definition json.hpp:18278
basic_json(const value_t v)
create an empty value with a given type
Definition json.hpp:18909
size_type max_size() const noexcept
returns the maximum possible number of elements
Definition json.hpp:21028
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json diff(const basic_json &source, const basic_json &target, const std::string &path="")
creates a diff as a JSON patch
Definition json.hpp:22919
iterator find(KeyType &&key)
find an element in a JSON object
Definition json.hpp:20723
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(detail::span_input_adapter &&i, const bool strict=true, const bool allow_exceptions=true)
Definition json.hpp:22486
static std::vector< std::uint8_t > to_bson(const basic_json &j)
create a BSON serialization of a given JSON value
Definition json.hpp:22257
value_type & reference
the type of an element reference
Definition json.hpp:18311
void erase(const size_type idx)
remove element from a JSON array given an index
Definition json.hpp:20663
const_reverse_iterator crend() const noexcept
returns a const reverse iterator to one before the first
Definition json.hpp:20896
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
Definition json.hpp:20114
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
Definition json.hpp:20076
iterator begin() noexcept
returns an iterator to the first element
Definition json.hpp:20811
binary_t & get_binary()
get a binary value
Definition json.hpp:19995
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
Definition json.hpp:19123
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
Definition json.hpp:22180
friend bool operator==(ScalarType lhs, const_reference rhs) noexcept
comparison: equal
Definition json.hpp:21710
basic_json(const JsonRef &ref)
Definition json.hpp:19233
static std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
Definition json.hpp:22157
basic_json & operator=(basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
copy assignment
Definition json.hpp:19322
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
Definition json.hpp:19095
const_reverse_iterator rend() const noexcept
returns an iterator to the reverse-end
Definition json.hpp:20882
const_iterator cend() const noexcept
returns an iterator to one past the last element
Definition json.hpp:20852
reference back()
access the last element
Definition json.hpp:20449
const binary_t & get_binary() const
get a binary value
Definition json.hpp:20007
static bool accept(InputType &&i, const bool ignore_comments=false)
check if the input is valid JSON
Definition json.hpp:22001
static void to_bjdata(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
Definition json.hpp:22249
StringType string_t
a type for a string
Definition json.hpp:18449
size_type size() const noexcept
returns the number of elements
Definition json.hpp:20989
void push_back(const basic_json &val)
add an object to an array
Definition json.hpp:21166
reference at(KeyType &&key)
access specified object element with bounds checking
Definition json.hpp:20096
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
Definition json.hpp:18350
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
Definition json.hpp:20389
ObjectType< StringType, basic_json, default_object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > > > object_t
a type for an object
Definition json.hpp:18441
std::size_t size_type
a type to represent container sizes
Definition json.hpp:18318
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
Definition json.hpp:19888
std::ptrdiff_t difference_type
a type to represent differences between iterators
Definition json.hpp:18316
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
Definition json.hpp:19051
reference operator+=(basic_json &&val)
add an object to an array
Definition json.hpp:21158
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
Definition json.hpp:18943
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
Definition json.hpp:18326
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
Definition json.hpp:22518
size_type count(const typename object_t::key_type &key) const
returns the number of occurrences of a key in a JSON object
Definition json.hpp:20753
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
Definition json.hpp:22450
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
Definition json.hpp:18324
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
Definition json.hpp:22282
BooleanType boolean_t
a type for a boolean
Definition json.hpp:18453
void push_back(initializer_list_t init)
add an object to an object
Definition json.hpp:21229
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization
Definition json.hpp:19362
reference operator[](typename object_t::key_type key)
access specified object element
Definition json.hpp:20211
static bool accept(IteratorType first, IteratorType last, const bool ignore_comments=false)
check if the input is valid JSON
Definition json.hpp:22010
std::decay< ValueType >::type value(KeyType &&key, ValueType &&default_value) const
access specified object element with default value
Definition json.hpp:20357
IteratorType erase(IteratorType pos)
remove element given an iterator
Definition json.hpp:20470
const_iterator find(const typename object_t::key_type &key) const
find an element in a JSON object
Definition json.hpp:20707
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a BSON serialization of a given JSON value
Definition json.hpp:22266
friend bool operator!=(const_reference lhs, ScalarType rhs) noexcept
comparison: not equal
Definition json.hpp:21726
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
Definition json.hpp:22503
constexpr bool is_structured() const noexcept
return whether type is structured
Definition json.hpp:19398
friend bool operator<=(ScalarType lhs, const_reference rhs) noexcept
comparison: less than or equal
Definition json.hpp:21854
const_iterator begin() const noexcept
returns an iterator to the first element
Definition json.hpp:20820
void update(const_iterator first, const_iterator last, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition json.hpp:21460
friend bool operator<(const_reference lhs, ScalarType rhs) noexcept
comparison: less than
Definition json.hpp:21820
reference at(size_type idx)
access specified array element with bounds checking
Definition json.hpp:20030
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
Definition json.hpp:19084
reference front()
access the first element
Definition json.hpp:20435
constexpr bool is_primitive() const noexcept
return whether type is primitive
Definition json.hpp:19391
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
Definition json.hpp:19433
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
create a CBOR serialization of a given JSON value
Definition json.hpp:22173
void swap(object_t &other)
exchanges the values
Definition json.hpp:21551
constexpr bool is_object() const noexcept
return whether value is an object
Definition json.hpp:19447
bool contains(KeyType &&key) const
check the existence of an element in a JSON object
Definition json.hpp:20780
reference operator[](KeyType &&key)
access specified object element
Definition json.hpp:20264
const_reference front() const
access the first element
Definition json.hpp:20442
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
Definition json.hpp:19384
NumberFloatType number_float_t
a type for a number (floating-point)
Definition json.hpp:18465
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
a reverse iterator for a basic_json container
Definition json.hpp:18333
friend std::ostream & operator<<(std::ostream &o, const basic_json &j)
serialize to stream
Definition json.hpp:21920
friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
comparison: less than or equal
Definition json.hpp:21836
bool empty() const noexcept
checks whether the container is empty.
Definition json.hpp:20950
basic_json(const basic_json &other)
copy constructor
Definition json.hpp:19237
~basic_json() noexcept
destructor
Definition json.hpp:19343
const_iterator find(KeyType &&key) const
find an element in a JSON object
Definition json.hpp:20739
static std::vector< std::uint8_t > to_ubjson(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition json.hpp:22203
basic_json(basic_json &&other) noexcept
move constructor
Definition json.hpp:19305
friend bool operator>(ScalarType lhs, const_reference rhs) noexcept
comparison: greater than
Definition json.hpp:21879
bool contains(const typename object_t::key_type &key) const
check the existence of an element in a JSON object
Definition json.hpp:20771
static void to_ubjson(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition json.hpp:22222
friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
comparison: not equal
Definition json.hpp:21717
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts copies of element into array
Definition json.hpp:21357
friend bool operator<(ScalarType lhs, const_reference rhs) noexcept
comparison: less than
Definition json.hpp:21829
json_value m_value
the value of the current element
Definition json.hpp:22140
void swap(typename binary_t::container_type &other)
exchanges the values
Definition json.hpp:21596
friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
comparison: greater than or equal
Definition json.hpp:21886
void swap(array_t &other)
exchanges the values
Definition json.hpp:21536
reverse_iterator rend() noexcept
returns an iterator to the reverse-end
Definition json.hpp:20875
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
Definition json.hpp:19062
static iteration_proxy< iterator > iterator_wrapper(reference ref) noexcept
wrapper to access iterator member functions in range-based for
Definition json.hpp:20908
std::less< StringType > default_object_comparator_t
default object key comparator type The actual object key comparator type (object_comparator_t) may be...
Definition json.hpp:18432
ReferenceType get_ref() const
get a reference value (implicit)
Definition json.hpp:19935
const_reference at(KeyType &&key) const
access specified object element with bounds checking
Definition json.hpp:20134
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts range of elements into array
Definition json.hpp:21377
auto get() noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
Definition json.hpp:19875
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
Definition json.hpp:22605
const_iterator end() const noexcept
returns an iterator to one past the last element
Definition json.hpp:20845
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
Definition json.hpp:23062
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition json.hpp:19635
iteration_proxy< const_iterator > items() const noexcept
helper to access iterator member functions in range-based for
Definition json.hpp:20933
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements from initializer list into array
Definition json.hpp:21408
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
Definition json.hpp:18445
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
Definition json.hpp:19912
friend bool operator>(const_reference lhs, const_reference rhs) noexcept
comparison: greater than
Definition json.hpp:21861
const_reference operator[](KeyType &&key) const
access specified object element
Definition json.hpp:20288
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
Definition json.hpp:20540
constexpr bool is_boolean() const noexcept
return whether value is a boolean
Definition json.hpp:19412
iterator end() noexcept
returns an iterator to one past the last element
Definition json.hpp:20836
void swap(reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
Definition json.hpp:21507
void clear() noexcept
clears the contents
Definition json.hpp:21072
friend bool operator>=(ScalarType lhs, const_reference rhs) noexcept
comparison: greater than or equal
Definition json.hpp:21904
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition json.hpp:22356
constexpr bool is_binary() const noexcept
return whether value is a binary array
Definition json.hpp:19468
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
Definition json.hpp:19103
iterator insert(const_iterator pos, basic_json &&val)
inserts element into array
Definition json.hpp:21350
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
Definition json.hpp:22410
reference operator[](size_type idx)
access specified array element
Definition json.hpp:20152
friend bool operator>(const_reference lhs, ScalarType rhs) noexcept
comparison: greater than
Definition json.hpp:21870
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
create a BSON serialization of a given JSON value
Definition json.hpp:22273
std::decay< ValueType >::type value(const char *key, ValueType &&default_value) const
Definition json.hpp:20340
string_t value(KeyType &&key, const char *default_value) const
access specified object element with default value
Definition json.hpp:20380
reference at(const json_pointer &ptr)
access specified element via JSON Pointer
Definition json.hpp:22591
void swap(binary_t &other)
exchanges the values
Definition json.hpp:21581
iter_impl< basic_json > iterator
an iterator for a basic_json container
Definition json.hpp:18329
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
a const reverse iterator for a basic_json container
Definition json.hpp:18335
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
Definition json.hpp:22395
friend bool operator!=(ScalarType lhs, const_reference rhs) noexcept
comparison: not equal
Definition json.hpp:21735
static void to_ubjson(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition json.hpp:22214
const_reverse_iterator rbegin() const noexcept
returns an iterator to the reverse-beginning
Definition json.hpp:20868
string_t value(const char *key, const char *default_value) const
Definition json.hpp:20345
size_type count(KeyType &&key) const
returns the number of occurrences of a key in a JSON object
Definition json.hpp:20763
void swap(string_t &other)
exchanges the values
Definition json.hpp:21566
const_reference back() const
access the last element
Definition json.hpp:20458
friend bool operator<(const_reference lhs, const_reference rhs) noexcept
comparison: less than
Definition json.hpp:21742
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array
Definition json.hpp:19073
constexpr bool is_string() const noexcept
return whether value is a string
Definition json.hpp:19461
constexpr bool is_array() const noexcept
return whether value is an array
Definition json.hpp:19454
iterator insert_iterator(const_iterator pos, Args &&... args)
Definition json.hpp:21311
basic_json flatten() const
return flattened JSON value
Definition json.hpp:22619
friend bool operator>=(const_reference lhs, ScalarType rhs) noexcept
comparison: greater than or equal
Definition json.hpp:21895
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
Definition json.hpp:22104
void push_back(basic_json &&val)
add an object to an array
Definition json.hpp:21133
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
Definition json.hpp:22298
reference operator[](T *key)
Definition json.hpp:20249
constexpr bool is_number() const noexcept
return whether value is a number
Definition json.hpp:19419
friend std::ostream & operator>>(const basic_json &j, std::ostream &o)
serialize to stream
Definition json.hpp:21942
reference operator+=(initializer_list_t init)
add an object to an object
Definition json.hpp:21245
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
Definition json.hpp:19426
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
Definition json.hpp:18274
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a CBOR serialization of a given JSON value
Definition json.hpp:22166
detail::value_t value_t
Definition json.hpp:18264
size_type erase(KeyType &&key)
remove element from a JSON object given a key
Definition json.hpp:20656
friend class ::nlohmann::detail::parser
Definition json.hpp:18210
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
create a MessagePack serialization of a given JSON value
Definition json.hpp:22196
const_reference operator[](const typename object_t::key_type &key) const
access specified object element
Definition json.hpp:20233
detail::actual_object_comparator_t< basic_json > object_comparator_t
object key comparator type
Definition json.hpp:18473
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
Definition json.hpp:18917
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
Definition json.hpp:22465
const_reference operator[](size_type idx) const
access specified array element
Definition json.hpp:20198
AllocatorType< basic_json > allocator_type
the allocator type
Definition json.hpp:18321
nlohmann::byte_container_with_subtype< BinaryType > binary_t
a type for a packed binary type
Definition json.hpp:18469
JSONSerializer< T, SFINAE > json_serializer
Definition json.hpp:18268
void push_back(const typename object_t::value_type &val)
add an object to an object
Definition json.hpp:21198
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse(IteratorType first, IteratorType last, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
deserialize from a pair of character iterators
Definition json.hpp:21975
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
Definition json.hpp:20787
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition json.hpp:22341
basic_json patch(const basic_json &json_patch) const
applies a JSON patch
Definition json.hpp:22644
string_t value(const typename object_t::key_type &key, const char *default_value) const
access specified object element with default value
Definition json.hpp:20329
basic_json(CompatibleType &&val) noexcept(noexcept(//NOLINT(bugprone-forwarding-reference-overload, bugprone-exception-escape) JSONSerializer< U >::to_json(std::declval< basic_json_t & >(), std::forward< CompatibleType >(val))))
create a JSON value from compatible types
Definition json.hpp:18929
basic_json unflatten() const
unflatten a previously flattened JSON value
Definition json.hpp:22628
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
Definition json.hpp:18461
iterator find(const typename object_t::key_type &key)
find an element in a JSON object
Definition json.hpp:20693
reference operator+=(const typename object_t::value_type &val)
add an object to an object
Definition json.hpp:21221
const_iterator cbegin() const noexcept
returns a const iterator to the first element
Definition json.hpp:20827
friend bool operator<=(const_reference lhs, ScalarType rhs) noexcept
comparison: less than or equal
Definition json.hpp:21845
std::decay< ValueType >::type value(const KeyType &key, ValueType &&default_value) const
access specified object element with default value
Definition json.hpp:20308
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
Definition json.hpp:22089
basic_json(initializer_list_t init, bool type_deduction=true, value_t manual_type=value_t::array)
create a container (array or object) from an initializer list
Definition json.hpp:18995
const_reference at(size_type idx) const
access specified array element with bounds checking
Definition json.hpp:20053
iterator insert(const_iterator pos, const basic_json &val)
inserts element into array
Definition json.hpp:21330
constexpr bool is_discarded() const noexcept
return whether value is discarded
Definition json.hpp:19475
constexpr bool is_null() const noexcept
return whether value is null
Definition json.hpp:19405
friend void swap(reference left, reference right) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
Definition json.hpp:21524
static void to_bjdata(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
Definition json.hpp:22241
auto get() const noexcept(noexcept(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))) -> decltype(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))
get a (pointer) value (explicit)
Definition json.hpp:19834
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
Definition json.hpp:21279
static void to_msgpack(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a MessagePack serialization of a given JSON value
Definition json.hpp:22189
reference operator+=(const basic_json &val)
add an object to an array
Definition json.hpp:21190
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
Definition json.hpp:20645
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
Definition json.hpp:19110
static allocator_type get_allocator()
returns the allocator associated with the container
Definition json.hpp:18342
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition json.hpp:19646
reverse_iterator rbegin() noexcept
returns an iterator to the reverse-beginning
Definition json.hpp:20861
an internal type for a backed binary type
Definition json.hpp:5267
byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
Definition json.hpp:5288
BinaryType container_type
Definition json.hpp:5269
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
Definition json.hpp:5278
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
Definition json.hpp:5283
bool operator!=(const byte_container_with_subtype &rhs) const
Definition json.hpp:5307
void clear_subtype() noexcept
clears the binary subtype
Definition json.hpp:5336
byte_container_with_subtype() noexcept(noexcept(container_type()))
Definition json.hpp:5273
byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
Definition json.hpp:5295
constexpr bool has_subtype() const noexcept
return whether the value has a subtype
Definition json.hpp:5329
void set_subtype(subtype_type subtype_) noexcept
sets the binary subtype
Definition json.hpp:5314
constexpr subtype_type subtype() const noexcept
return the binary subtype
Definition json.hpp:5322
std::uint64_t subtype_type
Definition json.hpp:5270
bool operator==(const byte_container_with_subtype &rhs) const
Definition json.hpp:5301
deserialization of CBOR, MessagePack, and UBJSON values
Definition json.hpp:8529
binary_reader & operator=(const binary_reader &)=delete
binary_reader(InputAdapterType &&adapter, const input_format_t format=input_format_t::json) noexcept
create a binary reader
Definition json.hpp:8545
binary_reader & operator=(binary_reader &&)=default
binary_reader(const binary_reader &)=delete
bool sax_parse(const input_format_t format, json_sax_t *sax_, const bool strict=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
Definition json.hpp:8566
binary_reader(binary_reader &&)=default
general exception of the basic_json class
Definition json.hpp:3867
const int id
the id of the exception
Definition json.hpp:3876
static std::string diagnostics(std::nullptr_t)
Definition json.hpp:3887
static std::string diagnostics(const BasicJsonType *leaf_element)
Definition json.hpp:3893
static std::string name(const std::string &ename, int id_)
Definition json.hpp:3882
const char * what() const noexcept override
returns the explanatory string
Definition json.hpp:3870
exception indicating errors with iterators
Definition json.hpp:4018
static invalid_iterator create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4021
a template for a bidirectional iterator for the basic_json class This class implements a both iterato...
Definition json.hpp:12054
bool operator<(const iter_impl &other) const
comparison: smaller
Definition json.hpp:12517
iter_impl operator-(difference_type i) const
subtract from iterator
Definition json.hpp:12647
bool operator!=(const IterImpl &other) const
comparison: not equal
Definition json.hpp:12508
void set_end() noexcept
set the iterator past the last value
Definition json.hpp:12244
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
Definition json.hpp:12081
iter_impl & operator--()
pre-decrement (–it)
Definition json.hpp:12431
difference_type operator-(const iter_impl &other) const
return difference
Definition json.hpp:12658
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
Definition json.hpp:12163
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference >::type reference
defines a reference to the type iterated over (value_type)
Definition json.hpp:12090
reference operator*() const
return a reference to the value pointed to by the iterator
Definition json.hpp:12283
iter_impl(iter_impl &&) noexcept=default
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
Definition json.hpp:12570
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer >::type pointer
defines a pointer to the type iterated over (value_type)
Definition json.hpp:12085
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
Definition json.hpp:12188
pointer operator->() const
dereference the iterator
Definition json.hpp:12327
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
Definition json.hpp:12153
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
Definition json.hpp:12178
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition json.hpp:12750
iter_impl operator+(difference_type i) const
add to iterator
Definition json.hpp:12625
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
Definition json.hpp:12636
const object_t::key_type & key() const
return the key of an object iterator
Definition json.hpp:12725
bool operator==(const IterImpl &other) const
comparison: equal
Definition json.hpp:12472
bool operator>(const iter_impl &other) const
comparison: greater than
Definition json.hpp:12561
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
Definition json.hpp:12079
reference value() const
return the value of an iterator
Definition json.hpp:12741
iter_impl & operator++()
pre-increment (++it)
Definition json.hpp:12380
reference operator[](difference_type n) const
access to successor
Definition json.hpp:12687
bool operator<=(const iter_impl &other) const
comparison: less than or equal
Definition json.hpp:12552
iter_impl operator++(int) &
post-increment (it++)
Definition json.hpp:12369
std::bidirectional_iterator_tag iterator_category
Definition json.hpp:12076
iter_impl operator--(int) &
post-decrement (it–)
Definition json.hpp:12420
iter_impl & operator+=(difference_type i)
add to iterator
Definition json.hpp:12579
iter_impl & operator-=(difference_type i)
subtract from iterator
Definition json.hpp:12616
Definition json.hpp:13780
json_ref(json_ref &&) noexcept=default
value_type const & operator*() const
Definition json.hpp:13819
BasicJsonType value_type
Definition json.hpp:13782
json_ref(Args &&... args)
Definition json.hpp:13799
json_ref(const value_type &value)
Definition json.hpp:13788
value_type const * operator->() const
Definition json.hpp:13824
json_ref(std::initializer_list< json_ref > init)
Definition json.hpp:13792
json_ref(value_type &&value)
Definition json.hpp:13784
value_type moved_or_copied() const
Definition json.hpp:13810
a template for a reverse iterator class
Definition json.hpp:12792
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
Definition json.hpp:12801
typename Base::reference reference
the reference type for the pointed-to element
Definition json.hpp:12798
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
Definition json.hpp:12844
json_reverse_iterator & operator+=(difference_type i)
add to iterator
Definition json.hpp:12832
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
Definition json.hpp:12796
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
Definition json.hpp:12805
reference operator[](difference_type n) const
access to successor
Definition json.hpp:12856
json_reverse_iterator operator--(int) &
post-decrement (it–)
Definition json.hpp:12820
std::ptrdiff_t difference_type
Definition json.hpp:12794
difference_type operator-(const json_reverse_iterator &other) const
return difference
Definition json.hpp:12850
json_reverse_iterator operator+(difference_type i) const
add to iterator
Definition json.hpp:12838
json_reverse_iterator operator++(int) &
post-increment (it++)
Definition json.hpp:12808
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
Definition json.hpp:12862
json_reverse_iterator & operator--()
pre-decrement (–it)
Definition json.hpp:12826
reference value() const
return the value of an iterator
Definition json.hpp:12869
json_reverse_iterator & operator++()
pre-increment (++it)
Definition json.hpp:12814
bool end_array()
Definition json.hpp:6690
bool start_object(std::size_t=static_cast< std::size_t >(-1))
Definition json.hpp:6670
typename BasicJsonType::string_t string_t
Definition json.hpp:6632
bool binary(binary_t &)
Definition json.hpp:6665
bool boolean(bool)
Definition json.hpp:6640
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:6629
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:6631
typename BasicJsonType::binary_t binary_t
Definition json.hpp:6633
bool key(string_t &)
Definition json.hpp:6675
bool end_object()
Definition json.hpp:6680
bool start_array(std::size_t=static_cast< std::size_t >(-1))
Definition json.hpp:6685
bool parse_error(std::size_t, const std::string &, const detail::exception &)
Definition json.hpp:6695
bool number_integer(number_integer_t)
Definition json.hpp:6645
bool string(string_t &)
Definition json.hpp:6660
bool number_unsigned(number_unsigned_t)
Definition json.hpp:6650
bool null()
Definition json.hpp:6635
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:6630
bool number_float(number_float_t, const string_t &)
Definition json.hpp:6655
typename BasicJsonType::string_t string_t
Definition json.hpp:6325
json_sax_dom_callback_parser & operator=(const json_sax_dom_callback_parser &)=delete
bool start_object(std::size_t len)
Definition json.hpp:6387
bool key(string_t &val)
Definition json.hpp:6405
constexpr bool is_errored() const
Definition json.hpp:6520
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:6323
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:6322
bool null()
Definition json.hpp:6345
typename BasicJsonType::parser_callback_t parser_callback_t
Definition json.hpp:6327
bool start_array(std::size_t len)
Definition json.hpp:6458
~json_sax_dom_callback_parser()=default
json_sax_dom_callback_parser(const json_sax_dom_callback_parser &)=delete
typename BasicJsonType::binary_t binary_t
Definition json.hpp:6326
bool binary(binary_t &val)
Definition json.hpp:6381
bool number_integer(number_integer_t val)
Definition json.hpp:6357
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:6324
bool end_array()
Definition json.hpp:6475
typename BasicJsonType::parse_event_t parse_event_t
Definition json.hpp:6328
bool boolean(bool val)
Definition json.hpp:6351
bool number_unsigned(number_unsigned_t val)
Definition json.hpp:6363
json_sax_dom_callback_parser & operator=(json_sax_dom_callback_parser &&)=default
bool string(string_t &val)
Definition json.hpp:6375
bool number_float(number_float_t val, const string_t &)
Definition json.hpp:6369
bool end_object()
Definition json.hpp:6422
json_sax_dom_callback_parser(json_sax_dom_callback_parser &&)=default
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition json.hpp:6508
json_sax_dom_callback_parser(BasicJsonType &r, const parser_callback_t cb, const bool allow_exceptions_=true)
Definition json.hpp:6330
SAX implementation to create a JSON value from SAX events.
Definition json.hpp:6146
bool start_array(std::size_t len)
Definition json.hpp:6238
json_sax_dom_parser(const json_sax_dom_parser &)=delete
typename BasicJsonType::binary_t binary_t
Definition json.hpp:6152
json_sax_dom_parser & operator=(json_sax_dom_parser &&)=default
bool number_unsigned(number_unsigned_t val)
Definition json.hpp:6188
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:6148
bool boolean(bool val)
Definition json.hpp:6176
~json_sax_dom_parser()=default
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition json.hpp:6258
bool string(string_t &val)
Definition json.hpp:6200
bool end_object()
Definition json.hpp:6231
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:6149
bool start_object(std::size_t len)
Definition json.hpp:6212
bool null()
Definition json.hpp:6170
bool binary(binary_t &val)
Definition json.hpp:6206
constexpr bool is_errored() const
Definition json.hpp:6270
bool key(string_t &val)
Definition json.hpp:6224
json_sax_dom_parser(json_sax_dom_parser &&)=default
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:6150
json_sax_dom_parser & operator=(const json_sax_dom_parser &)=delete
bool number_float(number_float_t val, const string_t &)
Definition json.hpp:6194
bool end_array()
Definition json.hpp:6250
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true)
Definition json.hpp:6159
typename BasicJsonType::string_t string_t
Definition json.hpp:6151
bool number_integer(number_integer_t val)
Definition json.hpp:6182
JSON_HEDLEY_RETURNS_NON_NULL static JSON_HEDLEY_CONST const char * token_type_name(const token_type t) noexcept
return name of values of type token_type (only used for errors)
Definition json.hpp:6761
token_type
token types for the parser
Definition json.hpp:6738
@ value_float
an floating point number – use get_number_float() for actual value
@ begin_array
the character for array begin [
@ value_string
a string – use get_string() for actual value
@ end_array
the character for array end ]
@ uninitialized
indicating the scanner is uninitialized
@ parse_error
indicating a parse error
@ value_integer
a signed integer – use get_number_integer() for actual value
@ value_separator
the value separator ,
@ end_object
the character for object end }
@ literal_true
the true literal
@ begin_object
the character for object begin {
@ value_unsigned
an unsigned integer – use get_number_unsigned() for actual value
@ literal_null
the null literal
@ end_of_input
indicating the end of the input buffer
@ name_separator
the name separator :
@ literal_or_value
a literal or the begin of a value (only for diagnostics)
@ literal_false
the false literal
lexical analysis
Definition json.hpp:6811
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
Definition json.hpp:8129
token_type scan()
Definition json.hpp:8208
void skip_whitespace()
Definition json.hpp:8199
lexer & operator=(lexer &&)=default
bool skip_bom()
skip the UTF-8 byte order mark
Definition json.hpp:8185
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
Definition json.hpp:6822
constexpr position_t get_position() const noexcept
return position of last read token
Definition json.hpp:8139
constexpr number_integer_t get_number_integer() const noexcept
return integer value
Definition json.hpp:8111
typename lexer_base< BasicJsonType >::token_type token_type
Definition json.hpp:6820
lexer & operator=(lexer &)=delete
lexer(const lexer &)=delete
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
Definition json.hpp:8117
constexpr number_float_t get_number_float() const noexcept
return floating-point value
Definition json.hpp:8123
std::string get_token_string() const
Definition json.hpp:8147
JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message() const noexcept
return syntax error message
Definition json.hpp:8172
exception indicating other library errors
Definition json.hpp:4070
static other_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4073
exception indicating access out of the defined range
Definition json.hpp:4053
static out_of_range create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4056
exception indicating a parse error
Definition json.hpp:3965
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, BasicJsonContext context)
create a parse error exception
Definition json.hpp:3977
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:3985
const std::size_t byte
byte index of the parse error
Definition json.hpp:4002
Definition json.hpp:16984
const error_handler_t error_handler
error_handler how to react on decoding errors
Definition json.hpp:17916
const std::lconv * loc
the locale
Definition json.hpp:17901
std::array< char, 64 > number_buffer
a (hopefully) large enough character buffer
Definition json.hpp:17898
serializer(serializer &&)=delete
serializer & operator=(serializer &&)=delete
const char decimal_point
the locale's decimal point character
Definition json.hpp:17905
std::uint8_t state
Definition json.hpp:17326
std::size_t bytes
Definition json.hpp:17327
const char thousands_sep
the locale's thousand separator character
Definition json.hpp:17903
serializer & operator=(const serializer &)=delete
std::size_t undumped_chars
Definition json.hpp:17331
void dump(const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent=0)
internal implementation of the serialization function
Definition json.hpp:17039
const char indent_char
the indentation character
Definition json.hpp:17911
std::size_t bytes_after_last_accept
Definition json.hpp:17330
std::array< char, 512 > string_buffer
string buffer
Definition json.hpp:17908
JSON_PRIVATE_UNLESS_TESTED const bool ensure_ascii
Definition json.hpp:17324
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
Definition json.hpp:16999
serializer(const serializer &)=delete
string_t indent_string
the indentation string
Definition json.hpp:17913
exception indicating executing a member function with a wrong type
Definition json.hpp:4036
static type_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4039
JSON Pointer defines a string syntax for identifying a specific value within a JSON document.
Definition json.hpp:12911
friend json_pointer operator/(const json_pointer &lhs, string_t token)
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
Definition json.hpp:12995
void pop_back()
remove last reference token
Definition json.hpp:13023
friend json_pointer operator/(const json_pointer &lhs, std::size_t array_idx)
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
Definition json.hpp:13002
json_pointer parent_pointer() const
returns the parent of this JSON pointer
Definition json.hpp:13009
bool empty() const noexcept
return whether pointer points to the root document
Definition json.hpp:13061
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
Definition json.hpp:12980
void push_back(const string_t &token)
append an unescaped token at the end of the reference pointer
Definition json.hpp:13047
typename string_t_helper< RefStringType >::type string_t
Definition json.hpp:12933
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
Definition json.hpp:12962
friend json_pointer operator/(const json_pointer &lhs, const json_pointer &rhs)
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
Definition json.hpp:12987
friend class json_pointer
Definition json.hpp:12917
string_t to_string() const
return a string representation of the JSON pointer
Definition json.hpp:12943
friend bool operator==(json_pointer< RefStringTypeLhs > const &lhs, json_pointer< RefStringTypeRhs > const &rhs) noexcept
compares two JSON pointers for equality
Definition json.hpp:13751
const string_t & back() const
return last reference token
Definition json.hpp:13035
friend bool operator!=(json_pointer< RefStringTypeLhs > const &lhs, json_pointer< RefStringTypeRhs > const &rhs) noexcept
compares two JSON pointers for inequality
Definition json.hpp:13758
json_pointer & operator/=(string_t token)
append an unescaped reference token at the end of this JSON pointer
Definition json.hpp:12972
json_pointer(const string_t &s="")
create JSON pointer
Definition json.hpp:12937
void push_back(string_t &&token)
append an unescaped token at the end of the reference pointer
Definition json.hpp:13054
Definition parser.inl:1064
A TOML path.
Definition path.h:239
Base class for all library exceptions.
Definition exception.h:62
decltype(get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
Definition json.hpp:4781
constexpr bool is_array
Metafunction for determining if a type is, or is a reference to, a toml::array.
Definition forward_declarations.h:921
enum TOML_CLOSED_FLAGS_ENUM indentation
Combination mask of all indentation-enabling flags.
Definition forward_declarations.h:333
GLM_FUNC_DECL GLM_CONSTEXPR genType e()
Definition constants.inl:102
genType::value_type const * begin(genType const &v)
Definition range.hpp:70
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
Definition json.hpp:2508
#define JSON_HEDLEY_CONST
Definition json.hpp:1687
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
Definition json.hpp:971
#define JSON_HEDLEY_WARN_UNUSED_RESULT
Definition json.hpp:1317
#define JSON_PRIVATE_UNLESS_TESTED
Definition json.hpp:2471
#define NLOHMANN_JSON_VERSION_PATCH
Definition json.hpp:52
#define JSON_HEDLEY_LIKELY(expr)
Definition json.hpp:1582
#define JSON_HEDLEY_NON_NULL(...)
Definition json.hpp:1475
#define JSON_INTERNAL_CATCH(exception)
Definition json.hpp:2438
#define JSON_HEDLEY_RETURNS_NON_NULL
Definition json.hpp:1916
#define JSON_CATCH(exception)
Definition json.hpp:2437
#define JSON_ASSERT(x)
Definition json.hpp:2464
#define JSON_THROW(exception)
Definition json.hpp:2435
#define NLOHMANN_JSON_VERSION_MAJOR
Definition json.hpp:50
#define NLOHMANN_BASIC_JSON_TPL
Definition json.hpp:2517
#define JSON_HEDLEY_UNLIKELY(expr)
Definition json.hpp:1583
#define JSON_TRY
Definition json.hpp:2436
#define JSON_NO_UNIQUE_ADDRESS
Definition json.hpp:2417
#define NLOHMANN_JSON_VERSION_MINOR
Definition json.hpp:51
#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name)
Definition json.hpp:2692
#define JSON_HEDLEY_DIAGNOSTIC_POP
Definition json.hpp:972
#define JSON_EXPLICIT
Definition json.hpp:2729
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
Definition json.hpp:1265
#define JSON_HEDLEY_PURE
Definition json.hpp:1656
float position
Definition main.cpp:86
GeneratorWrapper< std::vector< T > > chunk(size_t size, GeneratorWrapper< T > &&generator)
Definition catch.hpp:4333
T const & operator+(T const &value, StreamEndStop)
Definition catch.hpp:538
auto operator+=(std::string &lhs, StringRef const &sr) -> std::string &
GLM_FUNC_DECL mat< 2, 2, T, Q > operator-(mat< 2, 2, T, Q > const &m)
Definition type_mat2x2.inl:355
GLM_FUNC_DECL mat< 2, 2, T, Q > operator*(mat< 2, 2, T, Q > const &m, T scalar)
Definition type_mat2x2.inl:413
Definition core_func_geometric.cpp:15
seed_t seed(text opt, text arg)
Definition lest.hpp:1214
detail namespace with internal helper functions
Definition json.hpp:109
typename std::enable_if< B, T >::type enable_if_t
Definition json.hpp:2862
typename T::reference reference_t
Definition json.hpp:3225
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().data(), std::declval< const Arg & >().size())) string_can_append_data
Definition json.hpp:3781
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
Definition json.hpp:165
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
Definition json.hpp:3310
typename T::key_compare detect_key_compare
Definition json.hpp:3294
decltype(T::from_json(std::declval< Args >()...)) from_json_function
Definition json.hpp:3234
is_detected< string_can_append_iter, StringType, Arg > detect_string_can_append_iter
Definition json.hpp:3778
void to_json(BasicJsonType &j, T b) noexcept
Definition json.hpp:5047
value_type_t< iterator_traits< iterator_t< T > > > range_value_t
Definition json.hpp:3406
value_t
the JSON type enumeration
Definition json.hpp:139
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)
make_index_sequence< sizeof...(Ts)> index_sequence_for
Definition json.hpp:2966
typename T::pointer pointer_t
Definition json.hpp:3222
is_detected< string_can_append, StringType, Arg > detect_string_can_append
Definition json.hpp:3766
typename T::difference_type difference_type_t
Definition json.hpp:3219
typename detector< nonesuch, void, Op, Args... >::type detected_t
Definition json.hpp:2294
integer_sequence< size_t, Ints... > index_sequence
Definition json.hpp:2904
typename std::conditional< is_key_type_comparable< BasicJsonType, KeyTypeCVRef >::value &&!(ExcludeObjectKeyType &&std::is_same< KeyType, typename BasicJsonType::object_t::key_type >::value) &&(!RequireTransparentComparator||is_detected< detect_is_transparent, typename BasicJsonType::object_comparator_t >::value) &&!is_json_iterator_of< BasicJsonType, KeyType >::value &&!is_json_pointer< KeyType >::value, std::true_type, std::false_type >::type is_usable_as_key_type
Definition json.hpp:3663
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
Definition json.hpp:5170
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
Definition json.hpp:3403
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
Definition json.hpp:2307
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
Definition json.hpp:2848
decltype(std::declval< StringType & >().append(std::declval< Arg && >())) string_can_append
Definition json.hpp:3763
cbor_tag_handler_t
how to treat CBOR tags
Definition json.hpp:8501
@ store
store tags as binary type
@ error
throw a parse_error exception in case of a tag
error_handler_t
how to treat decoding errors
Definition json.hpp:16976
@ strict
throw a type_error exception in case of invalid UTF-8
@ ignore
ignore invalid UTF-8 sequences
@ replace
replace invalid UTF-8 sequences with U+FFFD
typename std::conditional< is_detected< detect_erase_with_key_type, typename BasicJsonType::object_t, KeyType >::value, std::true_type, std::false_type >::type has_erase_with_key_type
Definition json.hpp:3675
typename T::key_type key_type_t
Definition json.hpp:3213
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
Definition json.hpp:2777
typename utility_internal::Gen< T, N >::type make_integer_sequence
Definition json.hpp:2950
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
Definition json.hpp:2303
typename detected_or< Default, Op, Args... >::type detected_or_t
Definition json.hpp:2300
void concat_into(OutStringType &)
Definition json.hpp:3759
void replace_substring(StringType &s, const StringType &f, const StringType &t)
replace all occurrences of a substring by another string
Definition json.hpp:2758
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
Definition json.hpp:2288
is_detected< string_can_append_data, StringType, Arg > detect_string_can_append_data
Definition json.hpp:3784
typename make_void< Ts... >::type void_t
Definition json.hpp:2250
OutStringType concat(Args &&... args)
Definition json.hpp:3843
make_integer_sequence< size_t, N > make_index_sequence
Definition json.hpp:2958
typename T::mapped_type mapped_type_t
Definition json.hpp:3210
decltype(std::declval< T >().template get< U >()) get_template_function
Definition json.hpp:3237
decltype(std::declval< ObjectType & >().erase(std::declval< KeyType >())) detect_erase_with_key_type
Definition json.hpp:3666
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().begin(), std::declval< const Arg & >().end())) string_can_append_iter
Definition json.hpp:3775
typename T::is_transparent detect_is_transparent
Definition json.hpp:3643
typename is_comparable< typename BasicJsonType::object_comparator_t, const key_type_t< typename BasicJsonType::object_t > &, KeyType >::type is_key_type_comparable
Definition json.hpp:3640
typename T::iterator_category iterator_category_t
Definition json.hpp:3228
std::size_t concat_length()
Definition json.hpp:3728
is_detected< string_can_append_op, StringType, Arg > detect_string_can_append_op
Definition json.hpp:3772
decltype(std::declval< StringType & >()+=std::declval< Arg && >()) string_can_append_op
Definition json.hpp:3769
T conditional_static_cast(U value)
Definition json.hpp:3697
decltype(T::to_json(std::declval< Args >()...)) to_json_function
Definition json.hpp:3231
typename T::value_type value_type_t
Definition json.hpp:3216
namespace for Niels Lohmann
Definition json.hpp:107
basic_json<> json
default specialization
Definition json.hpp:3136
bool operator!=(json_pointer< RefStringTypeLhs > const &lhs, json_pointer< RefStringTypeRhs > const &rhs) noexcept
Definition json.hpp:13758
bool operator==(json_pointer< RefStringTypeLhs > const &lhs, json_pointer< RefStringTypeRhs > const &rhs) noexcept
Definition json.hpp:13751
Definition core_func_geometric.cpp:91
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition json.hpp:23140
__pstl::__internal::__enable_if_execution_policy< _ExecutionPolicy, _ForwardIterator > remove(_ExecutionPolicy &&__exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp &__value)
Definition glue_algorithm_impl.h:484
__pstl::__internal::__enable_if_execution_policy< _ExecutionPolicy, _ForwardIterator2 > copy(_ExecutionPolicy &&__exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __result)
Definition glue_algorithm_impl.h:248
__pstl::__internal::__enable_if_execution_policy< _ExecutionPolicy, void > reverse(_ExecutionPolicy &&__exec, _BidirectionalIterator __first, _BidirectionalIterator __last)
Definition glue_algorithm_impl.h:533
__pstl::__internal::__enable_if_execution_policy< _ExecutionPolicy, _ForwardIterator2 > transform(_ExecutionPolicy &&__exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __result, _UnaryOperation __op)
Definition glue_algorithm_impl.h:318
__pstl::__internal::__enable_if_execution_policy< _ExecutionPolicy, void > fill(_ExecutionPolicy &&__exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp &__value)
Definition glue_algorithm_impl.h:408
__pstl::__internal::__enable_if_execution_policy< _ExecutionPolicy, void > destroy(_ExecutionPolicy &&__exec, _ForwardIterator __first, _ForwardIterator __last)
Definition glue_memory_impl.h:224
__pstl::__internal::__enable_if_execution_policy< _ExecutionPolicy, bool > none_of(_ExecutionPolicy &&__exec, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
Definition glue_algorithm_impl.h:48
__pstl::__internal::__enable_if_execution_policy< _ExecutionPolicy, _ForwardIterator2 > move(_ExecutionPolicy &&__exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first)
Definition glue_algorithm_impl.h:752
__pstl::__internal::__enable_if_execution_policy< _ExecutionPolicy, _ForwardIterator > find(_ExecutionPolicy &&__exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp &__value)
Definition glue_algorithm_impl.h:96
__pstl::__internal::__enable_if_execution_policy< _ExecutionPolicy, bool > all_of(_ExecutionPolicy &&__exec, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
__pstl::__internal::__enable_if_execution_policy< _ExecutionPolicy, _ForwardIterator1 > find_first_of(_ExecutionPolicy &&__exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __s_first, _ForwardIterator2 __s_last, _BinaryPredicate __pred)
Definition glue_algorithm_impl.h:128
root
Definition version.py:42
TOML_NODISCARD TOML_EXPORTED_FREE_FUNCTION parse_result TOML_CALLCONV parse(std::string_view doc, std::string_view source_path={})
Parses a TOML document from a string view.
Definition toml.hpp:15819
default JSONSerializer template argument
Definition json.hpp:5220
static auto from_json(BasicJsonType &&j, TargetType &val) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), val))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), val), void())
convert a JSON value to any value type
Definition json.hpp:5224
static auto from_json(BasicJsonType &&j) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))
convert a JSON value to any value type
Definition json.hpp:5234
static auto to_json(BasicJsonType &j, TargetType &&val) noexcept(noexcept(::nlohmann::to_json(j, std::forward< TargetType >(val)))) -> decltype(::nlohmann::to_json(j, std::forward< TargetType >(val)), void())
convert any value type to a JSON value
Definition json.hpp:5244
typename BasicJsonType::default_object_comparator_t object_comparator_t
Definition json.hpp:3304
typename std::conditional< has_key_compare< object_t >::value, typename object_t::key_compare, object_comparator_t >::type type
Definition json.hpp:3306
typename BasicJsonType::object_t object_t
Definition json.hpp:3303
Op< Args... > type
Definition json.hpp:2284
std::true_type value_t
Definition json.hpp:2283
Default type
Definition json.hpp:2277
std::false_type value_t
Definition json.hpp:2276
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
Definition json.hpp:4959
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
Definition json.hpp:4988
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
Definition json.hpp:4972
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
Definition json.hpp:4947
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
Definition json.hpp:4937
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
Definition json.hpp:4876
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
Definition json.hpp:4885
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
Definition json.hpp:4830
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
Definition json.hpp:4898
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
Definition json.hpp:4924
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
Definition json.hpp:4911
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
Definition json.hpp:5017
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
Definition json.hpp:5007
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
Definition json.hpp:5028
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
Definition json.hpp:4852
static void construct(BasicJsonType &j, const CompatibleStringType &str)
Definition json.hpp:4863
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
Definition json.hpp:4843
typename BasicJsonType::template json_serializer< T, void > serializer
Definition json.hpp:3256
typename BasicJsonType::template json_serializer< T, void > serializer
Definition json.hpp:3271
typename BasicJsonType::template json_serializer< T, void > serializer
Definition json.hpp:3286
T value_type
Definition json.hpp:2891
static constexpr std::size_t size() noexcept
Definition json.hpp:2892
an iterator value
Definition json.hpp:11996
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition json.hpp:12002
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition json.hpp:12000
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
Definition json.hpp:11998
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
Definition json.hpp:3569
std::numeric_limits< RealIntegerType > RealLimits
Definition json.hpp:3568
typename BasicJsonType::object_t object_t
Definition json.hpp:3428
static constexpr auto value
Definition json.hpp:3478
nlohmann::detail::is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< !std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value &&!is_compatible_string_type< BasicJsonType, ConstructibleArrayType >::value &&is_default_constructible< ConstructibleArrayType >::value &&(std::is_move_assignable< ConstructibleArrayType >::value||std::is_copy_assignable< ConstructibleArrayType >::value)&&is_detected< iterator_t, ConstructibleArrayType >::value &&is_iterator_traits< iterator_traits< detected_t< iterator_t, ConstructibleArrayType > > >::value &&is_detected< range_value_t, ConstructibleArrayType >::value &&!std::is_same< ConstructibleArrayType, detected_t< range_value_t, ConstructibleArrayType > >::value &&is_complete_type< detected_t< range_value_t, ConstructibleArrayType > >::value > >::value_type range_value_t< ConstructibleArrayType > value_type
Definition json.hpp:3540
typename BasicJsonType::object_t object_t
Definition json.hpp:3452
static constexpr auto value
Definition json.hpp:3485
char one
Definition json.hpp:3682
@ value
Definition json.hpp:3692
static one test(decltype(&C::capacity))
static constexpr bool value
Definition json.hpp:3399
T & reference
Definition json.hpp:3054
T * pointer
Definition json.hpp:3053
T value_type
Definition json.hpp:3051
std::random_access_iterator_tag iterator_category
Definition json.hpp:3050
ptrdiff_t difference_type
Definition json.hpp:3052
typename It::difference_type difference_type
Definition json.hpp:3027
typename It::reference reference
Definition json.hpp:3030
typename It::iterator_category iterator_category
Definition json.hpp:3031
typename It::pointer pointer
Definition json.hpp:3029
typename It::value_type value_type
Definition json.hpp:3028
void type
Definition json.hpp:2248
nonesuch(nonesuch const &)=delete
void operator=(nonesuch &&)=delete
nonesuch(nonesuch const &&)=delete
void operator=(nonesuch const &)=delete
struct to capture the start position of the current token
Definition json.hpp:2812
std::size_t lines_read
the number of lines read
Definition json.hpp:2818
std::size_t chars_read_current_line
the number of characters read in the current line
Definition json.hpp:2816
std::size_t chars_read_total
the total number of characters read
Definition json.hpp:2814
static constexpr T value
Definition json.hpp:2980
auto operator()(BasicJsonType &j, T &&val) const noexcept(noexcept(to_json(j, std::forward< T >(val)))) -> decltype(to_json(j, std::forward< T >(val)), void())
Definition json.hpp:5192
typename Extend< typename Gen< T, N/2 >::type, N/2, N % 2 >::type type
Definition json.hpp:2931
a minimal map-like container that preserves insertion order
Definition json.hpp:17948
T & at(const Key &key)
Definition json.hpp:17995
std::vector< std::pair< const Key, T >, Allocator > Container
Definition json.hpp:17951
T mapped_type
Definition json.hpp:17950
const T & at(const Key &key) const
Definition json.hpp:18008
iterator find(const Key &key)
Definition json.hpp:18105
iterator erase(iterator pos)
Definition json.hpp:18040
void insert(InputIt first, InputIt last)
Definition json.hpp:18152
std::pair< iterator, bool > insert(value_type &&value)
Definition json.hpp:18129
const_iterator find(const Key &key) const
Definition json.hpp:18117
Key key_type
Definition json.hpp:17949
size_type erase(const Key &key)
Definition json.hpp:18021
T & operator[](const Key &key)
Definition json.hpp:17985
iterator erase(iterator first, iterator last)
Definition json.hpp:18045
typename Container::const_iterator const_iterator
Definition json.hpp:17953
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
Definition json.hpp:18149
ordered_map(It first, It last, const Allocator &alloc=Allocator())
Definition json.hpp:17967
std::equal_to< Key > key_compare
Definition json.hpp:17959
ordered_map(const Allocator &alloc) noexcept(noexcept(Container(alloc)))
Definition json.hpp:17965
std::pair< iterator, bool > insert(const value_type &value)
Definition json.hpp:18134
typename Container::size_type size_type
Definition json.hpp:17954
typename Container::value_type value_type
Definition json.hpp:17955
ordered_map(std::initializer_list< value_type > init, const Allocator &alloc=Allocator())
Definition json.hpp:17969
ordered_map() noexcept(noexcept(Container()))
Definition json.hpp:17964
size_type count(const Key &key) const
Definition json.hpp:18093
typename Container::iterator iterator
Definition json.hpp:17952
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
Definition json.hpp:17972
const T & operator[](const Key &key) const
Definition json.hpp:17990
std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL &j) const
Definition json.hpp:23113
bool operator()(nlohmann::detail::value_t lhs, nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values
Definition json.hpp:23127